react-native

React Native Swiper中的onIndexChan

2018-10-08  本文已影响0人  丶晓虎

RN版本5.5

React Native Swiper版本1.5.13

在代码中写明了

 <Swiper style={styles.swiper}
                                height={996}
                                horizontal={true}
                                paginationStyle ={{bottom:10}}
                                showsButtons={false}
                                loop={false}
                                showsPagination={false}
                                autoplay={false}
                                onIndexChanged={(index) => {
                                    var title = "Num " + index;
                                    this.setState({
                                        currentSelect: title,
                                    });
                                }}
                        >
                            {this.loadQueList()}
                        </Swiper>

却无法执行,后来搜索了下GitHub才发现解决方案。
定位到

/node_modules/react-native-swiper/src/index.js

把这句话(在274行)

const offset = this.internals.offset = {}

改为

const offset = this.internals.offset = {x:0, y:0}

问题解决~

上一篇 下一篇

猜你喜欢

热点阅读