ReactNative首页面,tab对应的页面传递参数:
tab携带参数:createStackNavigator({Home: HomeScene},{initialRouteParams:{“bai”:“漠天”}}),
const Tab = createBottomTabNavigator(
{
Home: {
screen: createStackNavigator({Home: HomeScene},{initialRouteParams:{"bai":"漠天"}}),
navigationOptions: ({navigation}) => ({
tabBarLabel: "Home",
tabBarIcon: ({focused, tintColor}) => (
<TabBarItem
tintColor={tintColor}
focused={focused}
normalImage={require("./img/tabbar_home.png")}
selectedImage={require("./img/tabbar_home_selected.png")}
/>
)
})
},
Mine: {
screen: createStackNavigator({Mine: MineScene}),
navigationOptions: ({navigation}) => ({
tabBarLabel: "Mine",
tabBarIcon: ({focused, tintColor}) => (
<TabBarItem
tintColor={tintColor}
focused={focused}
normalImage={require("./img/tabbar_mine.png")}
selectedImage={require("./img/tabbar_mine_selected.png")}
/>
)
})
}
},
页面中获取:
constructor(props){
super(props);
console.log("11111111111 传递的参数="+JSON.stringify(props))
}
打印结果:
LOG 11111111111 传递的参数={"navigation":{"state":{"params":{"bai":"漠天"},"routeName":"Home","key":"id-1623929067175-12"},"actions":{}}}