【问题标题】:@philly25/react-native-paytm Paytm.Events.PAYTM_RESPONSE reponse is undefined@philly25/react-native-paytm Paytm.Events.PAYTM RESPONSE 响应未定义
【发布时间】:2021-07-07 10:49:11
【问题描述】:

当我使用来自@philly25/react-native-paytm 的这段代码时,我在控制台中变得未定义

请帮忙

  componentDidMount() {
    Paytm.addListener(Paytm.Events.PAYTM_RESPONSE, this.onPayTmResponse());
  }

  componentWillUnmount() {
    Paytm.removeListener(Paytm.Events.PAYTM_RESPONSE, this.onPayTmResponse());
  }

  onPayTmResponse = (resp) => {
    console.log("hi " + resp);  // here getting undefined
}

【问题讨论】:

    标签: javascript react-native paytm


    【解决方案1】:

    我认为代码应该如下:

     componentDidMount() {
        Paytm.addListener(Paytm.Events.PAYTM_RESPONSE, this.onPayTmResponse);
      }
    
      componentWillUnmount() {
        Paytm.removeListener(Paytm.Events.PAYTM_RESPONSE, this.onPayTmResponse);
      }
    
      onPayTmResponse = (resp) => {
        console.log("hi " + resp);  // here getting undefined
      }
    

    查看官方包文档了解更多信息。

    https://github.com/opsway/react-native-paytm#readme

    【讨论】:

    • 是的。当我删除那个括号 () 然后 onPayTmResponse 甚至没有调用任何打印在那里。这就是为什么添加()。但现在它变得不确定
    • 我已经更新了答案,请查看官方文档了解更多信息
    【解决方案2】:

    这不是 Paytm 官方代码,请使用 Paytm github 链接上的插件。欲了解更多信息,请访问 Paytm 开发者门户

    【讨论】:

      猜你喜欢
      • 2019-10-12
      • 2017-12-16
      • 2021-06-21
      • 2021-09-15
      • 2016-09-26
      • 2022-01-21
      • 2021-11-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多