【发布时间】:2017-04-16 12:02:17
【问题描述】:
以 https://reactnavigation.org/docs/intro/ 为例,它必须像这样工作:
static navigationOptions = ({ navigation }) => ({
title: `Chat with ${navigation.state.params.user}`,
});
但是函数没有调用
更新:
export default class MainMap extends React.Component {
...
onMarkerPress(marker) {
this.props.navigation.navigate('Description', marker);
}
...
}
export default class Description extends Component {
static navigationOptions = ({ navigation, screenProps }) => ({
title: navigation.state.params.item.name + "'s Profile!"
}); //No text in the header
...
}
【问题讨论】:
-
我帮助重写了教程的那一部分,并且仍然有一个可以很好地运行代码的示例项目。您可以发布其余的代码吗?可能是复制不正确。
-
已更新 --------------
-
奇怪,我更改了该教程的示例代码来完成您正在做的事情并且它可以工作。您的
marker对象中有什么?它看起来像这样吗?{ item: { name: 'Lucy' } }另外,当您说标题中没有文本时,您甚至没有得到's Profile吗? -
我遇到了完全相同的问题。 @MichaelCheng 可以看看stackoverflow.com/questions/43485514/… 吗?谢谢
标签: react-native react-navigation