Kar*_*ala 3 react-native react-navigation
我正在使用react-navigation进行路由.我想在一个组件上动态隐藏或显示标题.有办法吗?
我像这样动态更改headerLeft但无法找到任何方法来为整个标头执行此操作.
static navigationOptions = ({ navigation }) => ({
headerRight: navigation.state.params ? navigation.state.params.headerRight : null
});
this.props.navigation.setParams({
headerRight: (
<View>
<TouchableOpacity onPress={() => blaa} >
<Text>Start</Text>
</TouchableOpacity>
</View>
)
});
Run Code Online (Sandbox Code Playgroud)
我想要这样的东西 - 隐藏/显示基于状态的标题:
this.props.navigation.setParams({
header: this.state.header
});
Run Code Online (Sandbox Code Playgroud)
Kar*_*ala 16
搞定了:
不知道为什么会这样,但传递undefined到标题将显示默认标题null并将隐藏标题.
我正在做这样的事情:
static navigationOptions = ({ navigation }) => ({
header: navigation.state.params ? navigation.state.params.header : undefined
});
Run Code Online (Sandbox Code Playgroud)
和国家变化;
this.props.navigation.setParams({
header: null
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4454 次 |
| 最近记录: |