Comments (2)
第一步,先安装axios
npm install -save axios
第二步 ,在所需文件引入axios
import axios from 'axios';
第三步,使用axios请求后台数据
componentDidMount() {
this.getTodos()
}
getTodos = async () => {
axios.get('/user', {
params: {
id: 12345,
name: user
}
})
.then(function (res) {
console.log(res);
})
.catch(function (err) {
console.log(err);
});
}
from blogs.
https://www.jianshu.com/p/53deecb09077
from blogs.
Related Issues (20)
- cookie,sessionStorage,localStorage的区别 HOT 1
- react中的路由的使用 HOT 1
- React中的refs作用 HOT 1
- hash路由和history路由的区别,他们的优缺点是什么 HOT 1
- async和await的用法 HOT 1
- 为什么不推荐用数组index作为key值遍历?会产生什么样的效果? HOT 1
- 使用useState更新不同对象,react hooks是怎么区分更新哪一个的? HOT 1
- 项目中的数据流向,this.props的来源问题
- react模块化开发 HOT 1
- react跨页面传值有哪些方法 HOT 1
- 受控组件和非受控组件的区别 HOT 1
- reactnative与flutter的区别,如何选择 HOT 1
- react中有没有类似泛型的类型?怎么使用
- 事件的节流与防抖是什么 HOT 1
- 怎么让多个页面使用同一个函数
- http状态码总结 HOT 1
- 对象转换为数组的直接方式
- 研究arguments对象
- 一、怎样才能让select里的内容居中显示? 二、表单输入框placeholder的文字能换行么? 三、怎么解决移动端与pc端之间的色差问题? HOT 1
- 什么是函数重载 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blogs.