沈陽網(wǎng)站建設(shè)技術(shù)公司百度客戶服務(wù)電話是多少
小程序頁面需要滑動功能
下拉時滑動,展示整個會員卡內(nèi)容,?下拉view里包含了最近播放:有scrollview,加了下拉功能后,scrollview滑動失敗了。
?
<view class="cover-section" catchtouchstart="handletouchstart" catchtouchmove="handletouchmove"catchtouchend="handlettouchend"style="transform:{{coverTransform}};transition:{{coverTransition}};"><view class="latest-section"><view class="lat_title">最近播放</view><scroll-view class="scroll1" scroll-x enable-flex="true"><view class="item" wx:for="{{playlist}}"><image class="item-img" src="{{item.song.al.picUrl?item.song.al.picUrl:'/static/images/recommendSong/02.jpg'}}"/><text class="item-value">{{item.song.al.name}}</text></view></scroll-view>
</view>
</view
?
問題所在:父元素使用了touchstart,touchmove,touchend三個事件,導(dǎo)致作為子元素的scroll-view組件無法滑動
解決辦法:父元素綁定touchstart事件時不要使用catch綁定,使用capture-bind:touchstart="fn"綁定,也就是捕獲模式,touchmove和touchend還是使用catch綁定
小知識1:為什么不用bind綁定touchstart,touchmove,touchend呢,因為使用bind會導(dǎo)致拖動元素時元素卡頓問題
小知識2:為什么touchmove和touchend不需要更改為使用capture-bind綁定呢,這個我試了一下,會導(dǎo)致scroll-view滑動事件和touchmove事件沖突,然后你滑動scroll-view組件時你添加了touchmove的那個元素(這是是scroll-view的父元素)也會動
解決:
catchtouchstart="handletouchstart"?改成:
capture-bind:touchstart="handletouchstart"?
滾動視圖滑動正常了。
<view class="cover-section" capture-bind:touchstart="handletouchstart" catchtouchmove="handletouchmove"catchtouchend="handlettouchend"style="transform:{{coverTransform}};transition:{{coverTransition}};"><view class="latest-section"><view class="lat_title">最近播放</view><scroll-view class="scroll1" scroll-x enable-flex="true"><view class="item" wx:for="{{playlist}}"><image class="item-img" src="{{item.song.al.picUrl?item.song.al.picUrl:'/static/images/recommendSong/02.jpg'}}"/><text class="item-value">{{item.song.al.name}}</text></view></scroll-view>
</view>
</view>
?