我为抽屉创建了一个单独的文件。我想在某些页面上禁用抽屉或其手势(滑动)。我尝试使用属性抽屉锁模式:“锁定关闭”和手势姿态:假。但是它们都不起作用。我为抽屉编写的代码是:
const CustomDrawerContentComponent = props => (
<View style={{ flex: 1 }}>
<DrawerScreen {...props} />
</View>
);
const Drawer2 = createDrawerNavigator(
{
Tab: {
screen: BooksNavigator,
},
EditProfile: {
screen: EditProfileNavigator,
},
Settings: {
screen: SettingsNavigator,
},
AboutUs: {
screen: AboutUsNavigator,
},
Help: {
screen: HelpNavigator,
},
MyContent: {
screen: MyContentNavigator,
},
},
{
drawerPosition: 'left',
drawerWidth: ScreenSize.width * 0.8,
contentComponent: CustomDrawerContentComponent,
},
);
const Drawer1 = createDrawerNavigator(
{
Tab: {
screen: MainNavigator,
},
EditProfile: {
screen: EditProfileNavigator,
},
Settings: {
screen: SettingsNavigator,
},
AboutUs: {
screen: AboutUsNavigator,
},
Help: {
screen: HelpNavigator,
},
MyContent: {
screen: MyContentNavigator,
},
},
{
drawerPosition: 'left',
drawerWidth: ScreenSize.width * 0.8,
contentComponent: CustomDrawerContentComponent,
},
);
Drawer2.navigationOptions = ({ navigation }) => {
let drawerLockMode = 'unlocked';
const gesturesEnabled = false;
console.log("Navigation in routes", navigation);
if (navigation.state.index > 0) {
drawerLockMode = 'locked-closed';
}
return {
drawerLockMode,
gesturesEnabled,
};
};
Drawer1.navigationOptions = ({ navigation }) => {
let drawerLockMode = 'unlocked';
const gesturesEnabled = false;
console.log("Navigation in routes", navigation);
if (navigation.state.index > 0) {
drawerLockMode = 'locked-closed';
}
return {
drawerLockMode,
gesturesEnabled,
};
};
这些属性似乎都不起作用。我还尝试从希望禁用抽屉的类中添加相同的属性。但是抽屉似乎仍然无法识别属性。