1、
mounted() {
var swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true,
observer:true //修改swiper自己或子元素时,自动初始化swiper
observeParents:true,//修改swiper的父元素时,自动初始化swiper
});
}
2、
mounted() {
window.onload = function() {
this.myswiper = new Swiper(".swiper-container", {
slidesPerView: "auto",
centeredSlides: true,
loop: true,
spaceBetween: 4,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
});
};
}
3、
// 如果是axios就放在axios的.then内
axios({
//....
}).then(res => {
this.$nextTick(function () {
this.swiperInit()
})
})