需要在mounted钩子函数中初始化:
new Vue({
el: "#app",
data() {
return {
swiperImg: ["images/1.png", "images/2.png", "images/3.png", "images/4.png"]
}
},
mounted() {
var mySwiper = new Swiper('.swiper-container', {
speed: 300,
direction: 'horizontal', // 垂直切换选项
loop: true, // 循环模式选项
autoplay: true,
effect: "fade",
// 如果需要分页器
pagination: '.pagination',
paginationClickable: true
})
}
})