axios封装
window.ajaxGet = function (that, myUrl, data, callback) {//创建一个ajax get请求that.$http.get(url + myUrl, { params: data, headers: headers }).then(response => {//用于读取类型与请求方式if ...
·
window.ajaxGet = function (that, myUrl, data, callback) { //创建一个ajax get请求
that.$http.get(url + myUrl, { params: data, headers: headers }).then(response => { //用于读取类型与请求方式
if (typeof (response) != "undefined") {
callback(response);
}
});
}
let Myurl="/api/Company";
let that=this;
let data= {
Index:(val-1)
};
ajaxGet(that,Myurl,data,function(r){
that.data=r.data.Data.Rows;
});
//callback 返回
window.ajaxPost = function (that, myUrl, data, callback) { //创建一个ajax 请求
that.$http.post(url + myUrl,stringify(data),{headers: headers}).then(response => {
if (typeof (response) != "undefined") {
callback(response);
}
});
}
//post同理
更多推荐
已为社区贡献1条内容
所有评论(0)