Vue.js
本章内容:
#### axios axios
是一个基于Promise 用于浏览器和 nodejs 的 HTTP 客户端,本质上也是对原生XHR的封装,只不过它是Promise的实现版本,符合最新的ES规范 。
示例语法
// 合用,既可以发get请求,又可以发post请求
axios({
url: "请求地址",
method: "get",
data: { // 参数
name: "",
age: ""
}
}).then((res) => {}).catch((err) => {})
// get语法
axios.get("请求地址",{
// 参数
params: {
name: "",
age: ""
}
}).then((res) => {}).cathch((err) => {})
// post语法
axios.post("请求地址",{
// 参数
name: "",
age: ""
}).then((res) => {}).catch((err) => {})