TabNavigator如何接受上个页面传过来的参数。



  • 上个页面是有传参数过来的
    const resetAction = NavigationActions.reset({
    index: 0,
    actions: [
    NavigationActions.navigate({routeName: 'Home', params: {theme: this.state.theme}})
    ]
    })
    this.props.navigation.dispatch(resetAction)

    下个页面的代码如下:
    export default HomeScene = TabNavigator(
    {
    MessageIndexScene: {
    screen: MessageIndexScene,
    navigationOptions: ({navigation}) => ({
    tabBarLabel: '消息',
    tabBarIcon: ({focused, tintColor}) => (
    <TabBarItem
    tintColor={tintColor}
    focused={focused}
    badgeText='4'
    normalImage={require('../Image/message_c.png')}
    selectedImage={require('../Image/message_o.png')}
    />
    )
    }),
    },
    ……
    TabNavigator如何接受上个页面传过来的参数。



  • 请问是否已经解决?我也遇到了这个需求,找了好久都没好到相应的属性设置。。。。o(╥﹏╥)o



  • const IndexScreen = TabNavigator({
    Home: {
    screen: HomeScreen,
    navigationOptions: function(res) {
    res.navigation.state.params = { test: '-------' };//可以在这里初始化params!,在home页面可以通过this.props.navigation.state.params得到
    return {
    tabBarLabel: '33',
    }
    }
    },
    Category: {
    screen: CategoryScreen
    }
    }, {
    // 懒加载
    lazy: true,
    navigationOptions: {
    // 首页没有后退按钮
    headerLeft: null
    },
    animationEnabled: false,
    swipeEnabled: false,
    tabBarComponent: TabBarBottom,
    tabBarPosition: 'bottom',
    tabBarOptions: {
    activeTintColor: '#F6AE23',
    inactiveTintColor: '#999',
    labelStyle: {
    fontSize: 10,
    },
    iconStyle: {
    height: 21,
    width: 21
    },
    style: {
    height: IsIphoneX ? 84 : 50,
    borderTopWidth: 0,
    paddingBottom: IsIphoneX ? 34 : 0
    },
    inactiveBackgroundColor: '#F4F4F4',
    activeBackgroundColor: '#F4F4F4'
    }
    })