- SEO之如何写标题Title
- 实战 Vue 之生命周期钩子函数执行顺序
- 关键词放在什么位置最好
- PHP内置变量如$_SERVER['DOCUMENT_ROOT'] 和 ../ 的用法
- JavaScript原生拖拽
- JavaScript中逻辑或运算符
- PHP中Trait详解
- Asp.net非常实用的51个代码(2)
- 有好货种草是什么意思?
- 微信小程序wx.getUserInfo获取用户所在地区为中文的方法
邮箱:
手机:15383239821
axios安装与使用
安装 cnpm install axios
三种get请求
// 第一种写法
axios.get('/query?name=tom').then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
});
// 第二种写法
axios.get('/query', {
params: {
name: 'tom'
}
}).then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
});
// 第三种写法
axios({
method: 'get',
url: '/query',
data: {
name: 'tom',
}
}).then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
});
post请求
axios.post('/query', {
name: 'tom',
icon: 'img_path'
}).then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
});
并发请求
function getUserAccount() {
return axios.get('/query?name=tom');
}
function getUserPermissions() {
return axios.get(/role?name=tom');
}
axios.all([getUserAccount(), getUserPermissions()])
.then(response) {
console.log(response);
// 两个请求都执行完成后返回,所有的请求结果都在这个res的对象下面
}));
- 上一篇:axios参数配置
- 下一篇:在VScode中开启自动换行
-
2023-10-09详解thinkphp模型
-
2020-01-29拼多多怎么提高留评率
-
2011-05-05数据库之间进行数据导入导出
-
2010-12-09写网站Title时应该注意什么?
-
2023-02-15img 图片找不到时,设置显示默认图片
-
2010-08-10关于asp.net Session丢失问题的总结
