路由对象参考
你应用中的每个 screen
组件都会自动收到 route
对象作为 prop。该 prop 包含有关当前路由(组件在导航层次结构中的位置)的各种信息。
route
key
- 屏幕的唯一键。自动创建或在导航到此屏幕时添加。name
- 屏幕的名称。在导航器组件层次结构中定义。path
- 一个可选字符串,包含打开屏幕的路径。当屏幕通过深度链接打开时存在。params
- 一个可选对象,包含在导航时定义的参数。例如:navigate('Twitter', { user: 'Dan Abramov' })
。
- 静态
- 动态
function ProfileScreen({ route }) {
return (
<View>
<Text>This is the profile screen of the app</Text>
<Text>{route.name}</Text>
</View>
);
}
function ProfileScreen({ route }) {
return (
<View>
<Text>This is the profile screen of the app</Text>
<Text>{route.name}</Text>
</View>
);
}