原代码:
//data_protion_list:网络数据
this.state = {
data_protion_list:[],
};
//render:
<Swiper
onIndexChanged = {this.onIndexChangedCenter.bind(this)}
ref="scrollView"
loop = {true}
key = {1000}
horizontal={true}
showsPagination = { false }
showsHorizontalScrollIndicator={false}
pagingEnabled={true}
>
{
this.state.data_protion_list.map((key, i) =>
this.renderPromotionView(key, i))
}
</Swiper>
在声明的时候设置好初始化长度,eg:
data_protion_list: ['','','','','','','','','','','','','','','']
推荐使用另外一个库:https://github.com/rilyu/teaset