我一直在嘗試進(jìn)行AJAX調(diào)用,然后在檢索完后將其添加到我的視圖中。當(dāng)前代碼沒(méi)有發(fā)生任何事情。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組件不呈現(xiàn)
狐的傳說(shuō)
2019-09-06 16:33:39