路由 prop 參考
應用程式中的每個 screen
畫面元件都會自動提供 route
prop。prop 包含各種資訊,關於目前的路由 (導航階層中元件所處的位置)。
路由
key
- 畫面的唯一金鑰。自動建立或在導引到此畫面時新增。name
- 畫面的名稱。在導航元件階層中定義。path
- 含開啟畫面的路徑之選用字串,在透過深度連結開啟畫面時存在。params
- 包含在導引時定義的 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>
);
}