问题描述:
用ajax动态加载swiper-slide以后,由于我是自适应屏幕的尺寸来决定一屏显示多少图片,所以加了 slidesPerView:'auto'这条属性,
加了这条属性过后,每次刷新页面的时候他总是跑到最后一张
亲测有效
分析:默认的是加载的空数组,等数组获取完再加载swiper组件,在swiper组件中增加一个v-if="list.length"
<swiper :options="swiperOption" v-if="list.length">
<swiper-slide v-for="item of list">
<img class="swiper-img" :src="item.imgUrl" :key='item.id'/>
</swiper-slide>
<div class="swiper-pagination" slot="pagination"></div>
</swiper>
.