componentDidMount(){
axios.get('url')
.then(response => this.setState({datasource: response.data}))
.catch(error => console.log("get data error"))
}
就这样写就可以直接完成设置状态。
componentDidMount(){
axios.get('url')
.then(response => this.setState({datasource: response.data}))
.catch(error => console.log("get data error"))
}
就这样写就可以直接完成设置状态。