<view @click="switchPrev">
<text>上一张</text>
</view>
<view @click="switchNext">
<text>下一张</text>
</view>
<swiper class="swiper" circular :current="current">
data() {
return {
current: 0
}
},
methods: {
/* this.current < 5 5代表swiper-item的数量 */
switchNext() {
if(this.current < 5){
this.current = ++this.current; // 通过改变current,自动切换
}else{
this.current = 0
}
},
switchPrev() {
if(this.current > 0){
this.current = --this.current; // 通过改变current,自动切换
}else{
this.current = 5
}
},
}
uniapp swiper添加点击切换 上一张 下一张
最新推荐文章于 2024-10-09 09:59:13 发布