【问题标题】:React native router flux params not working (are UNDEFINED)反应本机路由器通量参数不起作用(未定义)
【发布时间】:2018-11-27 16:21:49
【问题描述】:

我正在移动到另一个场景并发送参数,但是当我打印参数时(我使用 log.console({param: value}),我得到一个“未定义”。这是代码

<TouchableOpacity style={styles.addToOrderButton}
                              onPress={() => Actions.addToOrder({description: 'description', price: 'price'})}>
              <View style={{ flex: 1,justifyContent: 'center', alignItems: 'center'}}>
                <Text style={{color: '#FFF', fontSize: 12}}>Add to order</Text>
            </View></TouchableOpacity>

Router.js 是

<Drawer key="orders" contentComponent={DrawerMenu}>
         <Scene key="drawerMain" component={OrderMenu} title="Menu" initial />
         <Scene key="addToOrder" component={AddToOrder} title="Add to Order" />
        </Drawer>

有人有什么问题吗? 最好的问候!

【问题讨论】:

    标签: react-native react-native-router-flux


    【解决方案1】:

    在第二页你应该用这样的东西调用你的参数 你应该使用道具

    在 addToOrder 屏幕中

    console.log(this.props.description)

    【讨论】:

      【解决方案2】:

      问题是我正在使用 redux。这就是为什么不起作用

      【讨论】:

        【解决方案3】:

        我相信这与抽屉有关。

        在这里查看:https://github.com/aksonov/react-native-router-flux/issues/3374

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-07-18
          • 1970-01-01
          • 1970-01-01
          • 2020-10-27
          • 2016-12-04
          • 2019-10-12
          • 1970-01-01
          相关资源
          最近更新 更多