Riz*_*wan 5 javascript reactjs react-native react-navigation react-navigation-v5
我最近更新了我的项目以响应导航 5.x。在早期版本中,我们曾经设置标题标题如下:
static navigationOptions = ({ navigation }) => ({
title: 'find',
});
Run Code Online (Sandbox Code Playgroud)
这不适用于 React Navigation 5.x。请建议。
您可以通过 2 种方法来完成;
1:设置options为屏幕上的变量并保留当前代码:
<Stack.Screen
name="Label"
component={Component}
options={Component.navigationOptions}
/>
// component
static navigationOptions = {
title: 'find',
};
Run Code Online (Sandbox Code Playgroud)
2:通过setOptions在您的组件中使用:
<Stack.Screen
name="News"
component={News}
options={{
title: 'Default',
}}
/>
// component
this.props.navigation.setOptions({title: 'find'});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5161 次 |
| 最近记录: |