Skip to main content
Version: 7.x

TabAction 参考

TabActions 是一个对象,包含用于生成特定于基于选项卡的导航器的操作的方法。其方法扩展了 CommonActions 中可用的操作。

¥TabActions is an object containing methods for generating actions specific to tab-based navigators. Its methods expand upon the actions available in CommonActions.

支持以下操作:

¥The following actions are supported:

jumpTo

jumpTo 操作可用于跳转到选项卡导航器中的现有路由。

¥The jumpTo action can be used to jump to an existing route in the tab navigator.

  • name - string - 要跳转到的路由名称。

    ¥name - string - Name of the route to jump to.

  • params - object - 屏幕参数传递到目标路由。

    ¥params - object - Screen params to pass to the destination route.

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>
);
}
Try on Snack