小程序禁止swiper滑动

小程序中有时候我们要禁止用户滑动swiper组件,这时候catchtouchmove派上用场,在swiper-item上加上事件catchtouchmove即可。

// index.wxml
<swiper class='yaohe' vertical='true' circular='true' autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
  <block wx:for='{{yaohe}}'>
   <swiper-item catchtouchmove='catchTouchMove'>
      ...
   </swiper-item>
  </block>
</swiper>


// index.js
...
catchTouchMove() {
  return false;
},
...
本作品采用《CC 协议》,转载必须注明作者和本文链接
困困熊
Meriodas
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!