antd-mobile component library swiper not auto-scrolling issue


01 - Carousel component issue

Cause: Need to request backend data, so initial data is set to empty; but autoplay is set, causing conflict
Phenomenon: Initially does not auto-play, after you manually slide one it will auto-play

//get swiper data
  async getSwiper() {
    const {data,status} = await getSwiper()
    if (status === 200) {
      this.setState(
        {
          swiper: data
        }, () => {
          // because setstate is asynchronous, set the state in the callback after data is fetched to achieve reactivity
          this.setState({ isPlay: true})
        }
      )
    }
  }

评论

暂无评论。

登录后可发表评论。