React Component - 从fetch返回

时间:2017-02-10 01:06:39

标签: javascript reactjs ecmascript-6 react-redux

  1. 为什么this.getAccount()没有从获取中返回 json ?。
  2. 使用回调 this.getAccount(函数($){return $})仍然无法正常工作。
  3. 反应组件

      getAccount () {
        fetch('http://192.168.1.2:3000/account', {
          method: 'POST'
        }).then(function ($) {
          return $.json()
        }).then(function ($) {
          return $
        })
      }
      render () {
        return (
          <div>
            {
              this.getAccount()
            }
          </div>
        )
      }
    

0 个答案:

没有答案