路由对象参考
应用中的每个 screen 组件都会自动提供 route 对象作为 prop。该 prop 包含有关当前路由(导航层次结构组件中的位置)的各种信息。
¥Each screen component in your app is provided with the route object as a prop automatically. The prop contains various information regarding current route (place in navigation hierarchy component lives).
-
route-
key- 屏幕的唯一键。自动创建或在导航到此屏幕时添加。¥
key- Unique key of the screen. Created automatically or added while navigating to this screen. -
name- 屏幕名称。在导航器组件层次结构中定义。¥
name- Name of the screen. Defined in navigator component hierarchy. -
path- 当通过深层链接打开屏幕时,存在包含打开屏幕的路径的可选字符串。¥
path- An optional string containing the path that opened the screen, exists when the screen was opened via a deep link. -
params- 包含在导航时定义的参数的可选对象,例如navigate('Twitter', { user: 'Dan Abramov' })。¥
params- An optional object containing params which is defined while navigating e.g.navigate('Twitter', { user: 'Dan Abramov' }).
-
- Static
- Dynamic
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>
);
}