TabActions 参考
TabActions
是一个对象,包含用于生成特定于基于选项卡导航器的动作的方法。它的方法扩展了 CommonActions
中可用的动作。
支持以下动作
jumpTo
jumpTo
动作可以用于跳转到选项卡导航器中已存在的路由。
name
- *string* - 要跳转到的路由的名称。params
- *object* - 要传递给目标路由的屏幕参数。
- 静态
- 动态
function HomeScreen() {
const navigation = useNavigation();
const jumpToAction = TabActions.jumpTo('Profile', { user: 'Satya' });
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home!</Text>
<Button
onPress={() => {
navigation.dispatch(jumpToAction);
}}
>
Jump to Profile
</Button>
</View>
);
}
function HomeScreen() {
const navigation = useNavigation();
const jumpToAction = TabActions.jumpTo('Profile', { user: 'Satya' });
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home!</Text>
<Button
onPress={() => {
navigation.dispatch(jumpToAction);
}}
>
Jump to Profile
</Button>
</View>
);
}