DrawerActions 參考
DrawerActions
為一個物件,包含可以用於drawer 導航器特定動作的方法,其方法擴充套件自 CommonActions 當中提供的動作。
支援下列動作
openDrawer
openDrawer
動作可用來開啟 drawer 面板。
import { DrawerActions } from '@react-navigation/native';
navigation.dispatch(DrawerActions.openDrawer());
closeDrawer
closeDrawer
動作可用來關閉 drawer 面板。
import { DrawerActions } from '@react-navigation/native';
navigation.dispatch(DrawerActions.closeDrawer());
toggleDrawer
toggleDrawer
動作可用於在關閉時開啟 drawer 面板,開啟時關閉 drawer 面板。
import { DrawerActions } from '@react-navigation/native';
navigation.dispatch(DrawerActions.toggleDrawer());
jumpTo
jumpTo
動作可用於跳至 drawer 導航器的現有路線。
name
- 字串 - 要跳轉到的路線名稱。params
- 物件 - 傳遞至目的地路線的畫面參數。
import { DrawerActions } from '@react-navigation/native';
const jumpToAction = DrawerActions.jumpTo('Profile', { name: 'Satya' });
navigation.dispatch(jumpToAction);