小编김회준*_*김회준的帖子

react-native-swiper 下一个/上一个按钮事件

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)

swiper react-native

5
推荐指数
1
解决办法
5390
查看次数

标签 统计

react-native ×1

swiper ×1