react-native-viewpager icon indicating copy to clipboard operation
react-native-viewpager copied to clipboard

isLoop,autoPlay都为true,网络请求回来设置上去数据,Indicator会默认定到第二个上面去

Open sjimy opened this issue 10 years ago • 3 comments

export default class MainTabHomePage extends BasePage {

constructor(props) { super(props); this.state = { dataSource : new ViewPager.DataSource({pageHasChanged: (p1, p2) => p1 !== p2,}) }; }

componentDidMount(){ this.getHomeBanner();

}

getHomeBanner(){ RequestApi.getHomeBanner((result)=>{ this.setState({ dataSource:this.state.dataSource.cloneWithPages(result), }); },(errorCode,errorMsg)=>{ RequestApi.showErrorMsg(errorCode,errorMsg); }); }

render() { return (

);

}

sjimy avatar Oct 30 '16 10:10 sjimy

我也是,你解决了吗?而且我最后一张跳到第一张有跳跃

Silvia813 avatar Nov 13 '16 05:11 Silvia813

同问,我做完也是碰到这个问题!

Essun013 avatar Nov 25 '16 09:11 Essun013

我是这样处理的,需要将源码弄到本地(即3个js文件),然后import本地的,在ViewPager.js中加入方法

 setCurrentPageZero(){
        this.setState({
            currentPage: 0,
            viewWidth: 0,
        })
    },

然后在更新完数据后调用下此方法

 this.setState({
         dataSource: this.state.dataSource.cloneWithPages(IMGS2),
 }),
 this.pager.setCurrentPageZero()

tinylpc avatar Jan 06 '17 03:01 tinylpc