Problem a

Error message

TypeError: Cannot read property '? ' of undefined
    at HTMLElement._attached.wx.getPlatform._touchstartHandlerForDevtools
Copy the code

Solution: Because the mini program will retain the current from the last swiper slide, there will be no problem in the data of the last swiper slide. Therefore, before dynamically loading a Swiper item, you need to set the current property of swiper to 0

Question 2

Swiper is set to 0 each time, but swiper is still not displayed. Check that the element is present and current = -1

<swiper current='1'><swiper>
Copy the code

Set current = 0 and swiperList cannot be set in the same this.setData. So I’m going to setData swiperList and then setData Current and I’m going to say this:

This.setdata ({swiperItem: list},()=>{this.setdata ({current: 0})}) // Assign current in its callback after each assignment to swiperCopy the code

After that, no problem was solved successfully. I hope it will be helpful to you. Reference:

  1. Blog.csdn.net/m0_37270964…

  2. www.aiyingli.com/50779.html

  3. Developers.weixin.qq.com/community/d…

  4. Html52.com/archives/11…