vue-awesome-swiper中loop设置true无效
数据是动态加载的,在网上查不到和我相关的问题答案
是放在子组件中,首页直接引入此swiper子组件的
相关代码
<div class="wrapper" :class="cname">
<swiper :options="options">
<swiper-slide v-for="(item, index) in items" :key="index">
<slot :src="item"></slot>
</swiper-slide>
<div class="swiper-pagination" v-if="options.pagination" slot="pagination"></div>
</swiper>
</div>
name: "sliderComponent",
props: {
cname: {
type: String,
default: ""
},
options: {
type: Object,
default () {
return {
autoplay: {
delay: 3000,
disableOnInteraction: false,
//stopOnLastSlide: false
},
loop: true,
pagination: {
el: '.swiper-pagination'
},
observeParents:true,
observer:true
}
}
},
不循环了,轮播到最后一个图就不动了
试了好多次,终极答案是这样:
当然,在computed()时要获取$refs:
然后在vue生命周期的updated()时初始化swiper
不用v-if,获取到了this.swiper,问题完美解决