为了账号安全,请及时绑定邮箱和手机立即绑定

React - 用户定义的JSX组件不呈现

React - 用户定义的JSX组件不呈现

狐的传说 2019-09-06 16:33:39
我一直在尝试进行AJAX调用,然后在检索完后将其添加到我的视图中。当前代码没有发生任何事情。const View = () => (    <div>     <h1>Reports</h1>   <statisticsPage />    </div>);export default View;var statisticsPage = React.createClass({  getInitialState: function() {     return {info: "loading ... "};  },  componentDidMount: function() {     this.requestStatistics(1);  },  render: function() {    return (        <div>info: {this.state.info}</div>    );  },  requestStatistics:function(){      axios.get('api/2/statistics')      .then(res => {        values = res['data']        this.setState({info:1})        console.log('works!!')      });    }  })
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 680 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号