$nextTick的使用
watch监视数据变化,
¥nextTick在循环结束之后,获取更新完成之后的dom
watch: {
bannerList:{
handler(newValue,oldValue){
this.$nextTick(() => {
var mySwiper = new Swiper('.swiper', {
loop: true, // 循环模式选项
// 如果需要分页器
pagination: {
el: '.swiper-pagination',
},
// 如果需要前进后退按钮
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
})
}
}
}

浙公网安备 33010602011771号