swiper通过设置current切换页面,circular衔接效果失效
<
view
>
<
swiper
circular
=
"{{true}}"
current
=
"{{currentTap}}"
>
<
swiper-item
>
<
text
>11111111</
text
>
</
swiper-item
>
<
swiper-item
>
<
text
>2222</
text
>
</
swiper-item
>
<
swiper-item
>
<
text
>3333</
text
>
</
swiper-item
>
</
swiper
>
<
view
style
=
"display:flex;height:100rpx"
>
<
button
catchtap
=
"preBtn"
>上一页</
button
>
<
button
catchtap
=
"nextBtn"
>下一页</
button
>
</
view
>
</
view
>
data: {
currentTap: 0
},
preBtn:
function
() {
let newTap = 0;
if
(
this
.data.currentTap == 0) {
newTap = 2;
}
else
if
(
this
.data.currentTap == 1) {
newTap = 0;
}
else
if
(
this
.data.currentTap == 2) {
newTap = 1;
}
console.log(
'点击上一页 newTap:'
+ newTap +
' currentTap:'
+
this
.data.currentTap)
this
.setData({
currentTap: newTap
})
},
nextBtn:
function
() {
let newTap = 0;
if
(
this
.data.currentTap == 0) {
newTap = 1;
}
else
if
(
this
.data.currentTap == 1) {
newTap = 2;
}
else
if
(
this
.data.currentTap == 2) {
newTap = 0;
}
console.log(
'点击下一页 newTap:'
+ newTap +
' currentTap:'
+
this
.data.currentTap)
this
.setData({
currentTap: newTap
})
},
swiper组件设置circular衔接滑动时,手势左右滑动可达到衔接效果;
但是当通过设置current属性时,一直点击下一页,没有衔接效果;