vue swiper回調函數內傳值到vue數據內
vue swiper回調函數內傳值到vue數據,不能直接用this,因爲this指向的是當前swiper,所以需要在data內 定義self指向this
data() {
let self = this
return {
currentIndex: 0,
swiperOption:{
on: {
slideChangeTransitionEnd: function(){
self.currentIndex= sthis.activeIndex
},
},
}
}
}
上面回調函數是swiper從一個slide過渡到另一個slide結束時執行。獲取當前index的回調函數。
注意:Vue中,沒有在DOM元素中進行渲染的數據,是不會響應的。