我一直在嘗試進行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!!') }); } })
React - 用戶定義的JSX組件不呈現
狐的傳說
2019-09-06 16:33:39