一、无法竖屏
react-native-swiper 1.5.14版本无法竖屏滚动,需要切换到1.5.13版本就能正常切换,或者执行下面命令安装另一个库:(其实这个库也是1.5.13)
npm i @nart/react-native-swiper --save
import Swiper from '@nart/react-native-swiper'
二、禁用垂直滚动无效
得去修改node_model里的组件了,就是插件源代码,这里首先修改react-native-swiper/src/index.js:
static propTypes = {
.......
scrollEnabled: PropTypes.bool,//此处加入禁止滑动属性
.......
}
再修改垂直滑动用到的组件:react-native-vertical-view-pager/src/component/index.js:
<ScrollView
{...this.props}
ref={scrollview => this._refScrollView(scrollview)}
onLayout={e => this._onLayout(e)}
horizontal={false}
style={style}
// scrollEnabled={this.state.scrollEnabled}//此处去除它本身一直保持滑动状态
onScrollBeginDrag={e => this.onScrollBeginDrag(e)}
onScrollEndDrag={e => this.onScrollEndDrag(e)}
onMomentumScrollEnd={e => this.onMomentumScrollEnd(e)}
onScroll={e => this.onScroll(e)}
scrollEventThrottle={50}
contentContainerStyle={contentContainerStyle}>
{this.props.children}
</ScrollView>
网友评论