<div class="zpfirst" @click="changeSwipe('up')">
<van-icon name="arrow-left"/>
</div>
<van-swipe class="swipeDiv" ref="swiper">
<van-swipe-item v-for="item in remakes" :key="item.id">
</van-swipe-item>
</van-swipe>
<div class="zplast" @click="changeSwipe('down')">
<van-icon name="arrow"/>
</div>
//点击左右按钮实现左右切换
changeSwipe(type) {
if(type == 'up') {
this.index -= 1;
} else if (type == 'down') {
this.index += 1;
}
this.$refs.swiper.swipeTo(this.index);
},
vant-swipe点击切换
最新推荐文章于 2025-11-07 17:28:05 发布
本文介绍了一个使用Vue.js实现的滑动组件,通过点击左右按钮实现页面内容的左右切换。利用了vant UI库中的van-swipe和van-swipe-item组件,结合自定义方法changeSwipe()实现了流畅的切换效果。
1407





