vue—进行post和get请求
get请求:
this.axios.get("/user?" + "ID=" + 12345)
.then(res =>) {
console.log(res);
})
.catch(err =>) {
console.log(err);
this.$message({ message: "服务器错误" });
});
this.axios.get('/user', {
params: {
ID: 12345
}
})
.then(res =>) {
console.log(res);
})
.catch(err =>) {
console.log(err);
this.$message({ message: "服务器错误" });
});
post请求:
this.$axios.post('/user', {
userId: 1
})
.then(res => {
console.log(res);
});
.catch(err =>) {
console.log(err);
this.$message({ message: "服务器错误" });
});