Skip to main content
Version: 6.x

DrawerActions 参考

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

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

支持以下操作:

¥The following actions are supported:

openDrawer

openDrawer 动作可用于打开抽屉面板。

¥The openDrawer action can be used to open the drawer pane.

import { DrawerActions } from '@react-navigation/native';

navigation.dispatch(DrawerActions.openDrawer());

closeDrawer

closeDrawer 操作可用于关闭抽屉面板。

¥The closeDrawer action can be used to close the drawer pane.

import { DrawerActions } from '@react-navigation/native';

navigation.dispatch(DrawerActions.closeDrawer());

toggleDrawer

toggleDrawer 操作可用于打开抽屉面板(如果已关闭)或关闭(如果已打开)。

¥The toggleDrawer action can be used to open the drawer pane if closed, or close if open.

import { DrawerActions } from '@react-navigation/native';

navigation.dispatch(DrawerActions.toggleDrawer());

jumpTo

jumpTo 操作可用于跳转到抽屉式导航器中的现有路由。

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

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

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

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

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

import { DrawerActions } from '@react-navigation/native';

const jumpToAction = DrawerActions.jumpTo('Profile', { name: 'Satya' });

navigation.dispatch(jumpToAction);