1、get方式
let formData = {} //此乃入参数据
axios({
method: "get",
url: this.$config + "/qycqgz/importData",
params: formData, //这块注意入参的字段是params(王八的屁股--规定)
headers: { //根据不同类型的数据进行调整---这是文件流数据
"Content-Type":
"multipart/form-data;boundary = " + new Date().getTime(),
},
})
.then((res) => {
console.log(res, "成功");
})
.catch(function (error) {
console.log(error, "失败");
});
2、get方式
// 为给定 ID 的 user 创建请求
axios.get('/user?ID=12345')
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
// 上面的请求也可以这样做
axios.get('/user', {
params: {
ID: 12345
}
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
3、post方式
let formData = {} //此乃入参数据
axios({
method: "get",
url: this.$config + "/qycqgz/importData",
data: formData, //这块注意入参的字段是data(王八的屁股--规定)
headers: { //根据不同类型的数据进行调整---这是文件流数据
"Content-Type":
"multipart/form-data;boundary = " + new Date().getTime(),
},
})
.then((res) => {
console.log(res, "成功");
})
.catch(function (error) {
console.log(error, "失败");
});
4、post方式
axios.post('/user', {
firstName: 'Fred',
lastName: 'Flintstone'
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
// 发送 POST 请求
axios({
method: 'post',
url: '/user/12345',
data: {
firstName: 'Fred',
lastName: 'Flintstone'
}
});