react navigation 一般使用
navigation跳转并传值到下一个页面
pushaddremark(){ this.props.navigation.navigate("addRemarks", {info:"zhngsan",}); }
路由的routeName:"addRemarks"
路由的params:info
接受的一方怎么访问呢?
this.props.navigation可访问的内容有5个
dispatch()
goback()
navigate()
setParams()
state
this.props.navigation.state可访问的内容有
key
params
routeName
NavigationActions支持
Navigate:Reset:Back:Set Params:Init:
Navigate使用方法如下
import { NavigationActions } from 'react-navigation'
const navigationAction = NavigationActions.navigate({
routeName: 'Profile',
params: {},
// navigate can have a nested navigate action that will be run inside the child router
action: NavigationActions.navigate({ routeName: 'SubProfileRoute'})
})
this.props.navigation.dispatch(navigationAction)
Reset使用方法如下
import { NavigationActions } from 'react-navigation'
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'Profile'})
]
})
this.props.navigation.dispatch(resetAction)
SetParams使用方法如下
import { NavigationActions } from 'react-navigation'
const setParamsAction = NavigationActions.setParams({
params: {}, // these are the new params that will be merged into the existing route params
// The key of the route that should get the new params
key: 'screen-123',
})
this.props.navigation.dispatch(setParamsAction)

浙公网安备 33010602011771号