小程序頁(yè)面需要滑動(dòng)功能
下拉時(shí)滑動(dòng),展示整個(gè)會(huì)員卡內(nèi)容,?下拉view里包含了最近播放:有scrollview,加了下拉功能后,scrollview滑動(dòng)失敗了。
?
<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
?
問(wèn)題所在:父元素使用了touchstart,touchmove,touchend三個(gè)事件,導(dǎo)致作為子元素的scroll-view組件無(wú)法滑動(dòng)
解決辦法:父元素綁定touchstart事件時(shí)不要使用catch綁定,使用capture-bind:touchstart="fn"綁定,也就是捕獲模式,touchmove和touchend還是使用catch綁定
小知識(shí)1:為什么不用bind綁定touchstart,touchmove,touchend呢,因?yàn)槭褂胋ind會(huì)導(dǎo)致拖動(dòng)元素時(shí)元素卡頓問(wèn)題
小知識(shí)2:為什么touchmove和touchend不需要更改為使用capture-bind綁定呢,這個(gè)我試了一下,會(huì)導(dǎo)致scroll-view滑動(dòng)事件和touchmove事件沖突,然后你滑動(dòng)scroll-view組件時(shí)你添加了touchmove的那個(gè)元素(這是是scroll-view的父元素)也會(huì)動(dòng)
解決:
catchtouchstart="handletouchstart"?改成:
capture-bind:touchstart="handletouchstart"?
滾動(dòng)視圖滑動(dòng)正常了。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-630085.html
<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>
?文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-630085.html
到了這里,關(guān)于小程序 view下拉滑動(dòng)導(dǎo)致scrollview滑動(dòng)事件失效的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!