swiper 索引值按页面顺序出现。但是,当按下按钮时,索引值会上升到无穷大。
例如)下一个按钮点击-> 6/5、7/5、8/5
我想做的是在 5/5 停止按钮事件,但我不知道该怎么做。
https://github.com/leecade/react-native-swiper
应用程序.js
const renderPagination = (index, total, context) => {
return (
<View style={styles.paginationStyle}>
<Text style={{ color: 'grey' }}>
<Text style={styles.paginationText}>{index + 1}</Text>/{total}
</Text>
</View>
)
}
export default class App extends Component {
constructor(props){
super(props);
this.onPressNext = this.onPressNext.bind(this);
this.state = {
idxActive: 1
}
}
onPressPrev = () => {
this.refs.swiper.scrollBy(-1)
}
onPressNext = () => {
this.refs.swiper.scrollBy(1);
}
render() {
return (
<View style={styles.container}>
<Swiper
style={styles.wrapper}
renderPagination={renderPagination}
showsButtons={false}
loop={false}
ref={'swiper'}
> …Run Code Online (Sandbox Code Playgroud)