我一直在尝试进行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!!') }); } })
添加回答
举报
0/150
提交
取消