uniapp轮播swiper,使用方法以及我踩过的坑

 <swiper
        class="swipe-box"
        :current="curDot"
        @change="swiperChange"
        :disable-touch="true"
      >
      <template v-if="style_type === 0">
        <swiper-item v-for="i in 100"  @touchmove.stop>
        </swiper-item>
      </template>
      <template v-if="style_type === 1">
         <swiper-item v-for="i in 200"  @touchmove.stop>
        </swiper-item>
      </template>
  </swiper>

对于上述的参数说明:

:disable-touch="true"  //禁止用户触摸操作,页面滑动的时候禁止有别的触摸操作(小程序上无效)
@touchmove.stop //禁止用户通过手触摸滑动

爬坑:
1、v-if 和 v-for 不能同时使用,但是swiper-item不能使用 进行包裹,那么聪明如我,用template进行包裹就好啦 哈哈哈
2、swiper内不能包含行内样式不然会导致下一页的轮播渲染失败

猜你喜欢

转载自blog.csdn.net/qq_46566911/article/details/127809256