更新于 2018.11.08
目录 [TOC]
- this.props.navigation
- navigate - 跳转到另一个屏幕
1. navigation.navigate({ routeName, params, action, key }) 2. navigation.navigate(routeName, params, action)
- goBack - 关闭当前屏幕并返回上一个屏幕
- addListener - 添加对路由的监听
- isFocused
- state
- setParams
- getParam
- dispatch
- dangerouslyGetParent
- 如果是StackNavigator, this.props.navigation还有如下方法
- push
- pop
- popToTop
- replace
- reset
- dismiss
- 如果是DrawerNavigator, this.props.navigation还有如下方法
- openDrawer
- closeDrawer
- toggleDrawer
import { NavigationActions } from 'react-navigation';
- navigate
- back
- setParams
import { StackActions } from 'react-navigation';
- reset
- replace
- push
- pop
- popToTop
import { DrawerActions } from 'react-navigation-drawer';
- openDrawer - 打开抽屉
this.props.navigation.dispatch(DrawerActions.openDrawer());
- closeDrawer - 关闭抽屉
this.props.navigation.dispatch(DrawerActions.closeDrawer());
- toggleDrawer - 切换抽屉
this.props.navigation.dispatch(DrawerActions.toggleDrawer());
createStackNavigator(RouteConfigs, StackNavigatorConfig);
- screen
- path
- navigationOptions
- title
- header
- headerTitle
- headerTitleAllowFontScaling
- headerBackImage
- headerBackTitle
- headerTruncatedBackTitle
- headerRight
- headerLeft
- headerStyle
- headerForceInset
- headerTitleStyle
- headerBackTitleStyle
- headerLeftContainerStyle
- headerRightContainerStyle
- headerTitleContainerStyle
- headerTintColor
- headerPressColorAndroid
- headerTransparent
- headerBackground
- gesturesEnabled
- gestureResponseDistance
- horizontal
- vertical
- gestureDirection
- initialRouteName
- initialRouteParams
- initialRouteKey
- navigationOptions
- paths
- mode
- card
- modal
- headerMode
- float
- screen
- none
- headerBackTitleVisible
- headerTransitionPreset
- headerLayoutPreset
- cardStyle
- transitionConfig
- transitionProps
- prevTransitionProps
- isModal
- onTransitionStart
- onTransitionEnd
- transparentCard
Navigator Props
const SomeStack = createStackNavigator({
// config
});
<SomeStack
screenProps={/* this prop will get passed to the screen components as this.props.screenProps */}
/>
createSwitchNavigator(RouteConfigs, SwitchNavigatorConfig);
RouteConfigs - 同createStackNavigator的RouteConfigs
- initialRouteName
- resetOnBlur
- paths
- backBehavior
createDrawerNavigator(RouteConfigs, DrawerNavigatorConfig);
RouteConfigs - 同createStackNavigator的RouteConfigs
- navigationOptions
- title
- drawerLabel
- drawerIcon
- drawerLockMode
- drawerWidth
- drawerPosition
- contentComponent
- items
- activeItemKey
- activeTintColor
- activeBackgroundColor
- inactiveTintColor
- inactiveBackgroundColor
- onItemPress(route)
- itemsContainerStyle
- itemStyle
- labelStyle
- activeLabelStyle
- inactiveLabelStyle
- iconContainerStyle
- contentOptions
- useNativeAnimations
- drawerBackgroundColor
- initialRouteName
- order
- paths
- backBehavior
createTabNavigator(RouteConfigs, TabNavigatorConfig);
RouteConfigs - 同createStackNavigator的RouteConfigs
- navigationOptions
- title
- tabBarVisible
- swipeEnabled
- tabBarIcon
- tabBarLabel
- tabBarOnPress
- tabBarComponent
- TabBarBottom - (IOS默认)
- tabBarOptions
- activeTintColor
- activeBackgroundColor
- inactiveTintColor
- inactiveBackgroundColor
- showLabel
- style
- labelStyle
- tabStyle
- allowFontScaling
- safeAreaInset
- tabBarOptions
- TabBarTop - (Android默认)
- tabBarOptions
- activeTintColor
- inactiveTintColor
- showIcon
- showLabel
- upperCaseLabel
- pressColor
- pressOpacity
- scrollEnabled
- tabStyle
- indicatorStyle
- labelStyle
- iconStyle
- style
- allowFontScaling
- tabBarOptions
- TabBarBottom - (IOS默认)
- tabBarPosition
- swipeEnabled
- animationEnabled
- lazy
- removeClippedSubviews
- initialLayout
- tabBarOptions
- initialRouteName
- order
- paths
- backBehavior
createBottomTabNavigator(RouteConfigs, BottomTabNavigatorConfig);
RouteConfigs - 同createStackNavigator的RouteConfigs
- navigationOptions
- title
- tabBarVisible
- tabBarIcon
- tabBarLabel
- tabBarButtonComponent
- tabBarAccessibilityLabel
- tabBarTestID
- tabBarOnPress
- initialRouteName
- order
- paths
- backBehavior
- tabBarComponent
- tabBarOptions
- activeTintColor
- activeBackgroundColor
- inactiveTintColor
- inactiveBackgroundColor
- showLabel
- showIcon
- style
- labelStyle
- tabStyle
- allowFontScaling
- safeAreaInset
npm install react-navigation-material-bottom-tabs createMaterialBottomTabNavigator(RouteConfigs, MaterialBottomTabNavigatorConfig);