computed: {
swiper() {
return this.$refs.mySwiper.$swiper
},
}
在pre,next按钮上添加方法,调用this.swiper.slideNext()报错
因为在swiper组件上添加了v-else,组件会不停地展示,销毁;
但是因为computed的缓存特性,导致组件重新展示后没有去返回新的状态,使用的destroyed的旧对象,所以后面点击pre,next去调用swiper方法会报错
不用computed,直接用下面的方式调用方法就解决了
next() {
this.$refs.mySwiper.$swiper.slideNext()
},