Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

loop模式开启后,异步获取数据只能显示最后一个 #52

Closed
woodygithub opened this issue Mar 2, 2017 · 4 comments
Closed

Comments

@woodygithub
Copy link

notNextTick为true,initialSlide为1,

@surmon-china
Copy link
Owner

请帖出详细代码

@woodygithub
Copy link
Author

image

@woodygithub
Copy link
Author

woodygithub commented Mar 7, 2017

swiperOption:{
    notNextTick: true,
    direction : 'horizontal',
    initialSlide: 1,
    loop:true,
    onSlideChangeEnd:(swiper)=>{
        console.log(swiper.realIndex);
    },
    onTouchEnd:(swiper, event)=>{
                        
    },
    onTap:(swiper)=>{

    }
}

Model.getAllRecordInfo({
      userId : this.userData.userId,
      type : 1
}).then(data=>{
      Indicator.close();
      this.cars = data.data.carInRecords.concat( data.data.noneCarInRecords );
}).catch(data=>{
      Indicator.close();
      Toast.toast(data.msg);
})

异步请求数据,给cars整体赋值最后页面只能显示最后一页,使用的是vue 1.X不知道有没有关系

@surmon-china
Copy link
Owner

  • 首先,要确定异步数据拼接后,数据是否在预期之内。
  • initialSlide和异步数据本身不会有关系,数据更新时,组件仅执行了swiperupdate方法,此方法并不会重新实例化实例;正常的状态应该是,数据更新后,活动页应该正常停留的数据更新前的活动页,鉴于你所描述的现象,可能是因为数据更新时,活动页下标在最后一页或首页,和loop模式的节点复制产生了冲突,导致所看到的现象,具体原因需要多次测试,期待你的反馈,问题暂且关闭。

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants