在文件目录下执行安装命令:
npm add axios
在文件中引入
import axios from ‘axios‘
使用范例:
componentDidMount(){
axios.get(‘http://localhost:3001/todolist‘)
.then((res)=>(
this.setState({list : [...res.data]})
))
.catch(()=>{alert(‘error‘)})
console.log(‘componentDidMount‘)
}
原文:https://www.cnblogs.com/nothingness/p/13216567.html
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!