import axios from "axios";
一、get
mounted() {
axios
.get(
"/api/queryusertree?domId=" + this.domId + "&ownerId=" + this.ownerId,
{
headers: { Validate: "123456" }
}
)
.then(response => {
let object = response.data.data;
let head = object;
this.data = object.childList;
console.log(this.data);
})
.catch(error => {
console.log(error);
alert("网络错误,不能访问");
});
},
二、post
remove(userId) {
let data = {
domId: this.domId,
ownerId: this.ownerId,
userId: userId
};//post传递对象到后台
axios
.post("/api/removedomuser", data, {
headers: {
//头部信息
"Content-Type": "application/json;charset=utf-8",
Validate: "123456"
}
})
.then(response => {
let resultUtils = response.data;
console.log(resultUtils);
})
.catch(error => {
console.log(error);
alert("网络错误,不能访问");
});
},
标签:axios,console,log,get,domId,let,post,data
来源: https://www.cnblogs.com/yanl55555/p/11963743.html