如果想禁用全部界面
可以有下面二种方法:
方法一:
在使用Navigator时,配置configureScene的gestures为null
configureScene= {(route) => {
return ({
...Navigator.SceneConfigs.PushFromRight,
gestures: null
});
}
}
方法二:
自己定义个configureScene:
const NoBackSwipe = {
...Navigator.SceneConfigs.HorizontalSwipeJump,
gestures: {
pop: {}
}
};
然后在Navigator标签下使用
<Navigator
initialRoute={{Component:'xxx', name:'xxx', index:0, configure: NoBackSwipe}}
renderScene={this.renderScene.bind(this)}
configureScene={(route,routeStack)=>{
return NoBackSwipe
}}
/>
这里主要是处理了pop,其中还有jumpback,jumpforward的
如果你只是想禁用某些界面
那可以看下面代码:
首先在Navigator配置的时候不要写死是哪个手势,要传进来:
configureScene={(route) => ({
...route.sceneConfig || Navigator.SceneConfigs.PushFromRight,
gestures: route.gestures
})}
然后再你要跳转的时候,如果是要开启手势
的:
const{navigator} = this.props;
if(navigator){
navigator.push({
component: LoginView,
sceneConfig: Navigator.SceneConfigs.PushFromRight,
gestures: Navigator.SceneConfigs.PushFromRight.gestures
});
}
如果是要禁止手势
的:
const{navigator} = this.props;
if(navigator){
navigator.push({
component: Home,
sceneConfig: Navigator.SceneConfigs.PushFromRight,
gestures: null
});
}
网友评论