且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在反应本机导航器中禁用向后滑动手势

更新时间:2022-06-22 01:43:27

我按照下面的方式解决了,

I solved it below way,

在 React 项目中,我有 node_modules 文件夹.这个路径有导航组件的代码,

In React Project I have node_modules folder. There is code for Navigator component at this path,

/node_modules/react-native/Libraries/CustomComponents/Navigator/Navigator.js

/node_modules/react-native/Libraries/CustomComponents/Navigator/Navigator.js

在该文件中,有针对导航手势的操作.通过从那里移除弹出"手势,当从屏幕左边缘滑入时会停止弹出.

In that file There is actions for Gestures on Navigations. By removing 'pop' gesture from there stops poping back when slide in from left edge of the screen.

只需替换下面的代码,

var GESTURE_ACTIONS = [
  'pop',
  'jumpBack',
  'jumpForward',
];

使用此代码,

var GESTURE_ACTIONS = [
  'jumpBack',
  'jumpForward',
];