<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
}
},
}
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交