Swiper init script for mobile issue

Solution 1:

"Your mistake" under else if you forgot first to Initialize swiper instance .

This is why when you uncomment this block of code - the page is broken (error: this.swiper.destroy is undefined).

enter image description here

To destroy an instance you first should create this instance (destroy() is a Method of swiper instance).

const swiper = new Swiper('.swiper-container', {});
swiper.destroy();

Otherwise, your code is like writing:

bla_bla.destroy(); /* Uncaught ReferenceError: bla_bla is not defined */
  1. Create an instance (Missing in your code)
  2. Destroy
else if (!mobile_breakpoint.matches){
   var init = new Swiper(this, settings) /* missing in your code */
   init = this.swiper.destroy();
}

In general - your code is very long ==> next time create a Minimal, Reproducible Example (A lot of code not related to your issue/error).