[Vuejs]-How to destroy Swiper slider for VueJS

0👍

You can add eventListner on resize like following and destroySwiper can be method which will take care of your logic on how to destroy swiper slider:

ready: function () {
  window.addEventListener('resize', this.destroySwiper)
},
beforeDestroy: function () {
  window.removeEventListener('resize', this.destroySwiper)
}

0👍

You can add a ref to your template first, then access the swiper instance on that ref to destroy

this.$refs[yourRef].$swiper.destroy()

See https://swiperjs.com/swiper-api#method-swiper-destroy

👤dmtri

Leave a comment