当前位置: 代码迷 >> 综合 >> vue-awesome-swiper init方法无效
  详细解决方案

vue-awesome-swiper init方法无效

热度:64   发布时间:2023-11-19 18:21:05.0

解决办法

v-if来重新渲染 swiperVisible

<swiper class="swiper" :options="swiperOptionTop" ref="swiper1" v-if='swiperVisible'><swiper-slide class="slide-1" v-for='item in imgList'><img :src='item' /></swiper-slide>
</swiper>
export default {data() {return {swiperVisible:true,swiperOptionTop: slidesPerView: 3,spaceBetween: 10,}}},mounted(){this.swiperOptionTop.spaceBetween=20;//修改options配置this.swiperVisible=false;//通过v-if切换,重新渲染swiperthis.$nextTick(()=>{this.swiperVisible=false;});}
}

  相关解决方案