checkLogin: () => {
// 返回一个promise对象
return new Promise((resolve, reject) => {
axios({
url: url
method: 'post',
data: {
}
})
.then((res) => {
resolve(res.data);
// console.log(res);
})
.catch(function (error) {
reject(error);
// console.log(error);
});
});
}
调用
this.common.checkLogin()
.then(res => {
console.log(res);
// 执行成功的回调函数
},
error => { console.log(error);
// 执行失败的回调函数
});
this.common.checkLogin()
.then(res => {
console.log(res);
// 执行成功的回调函数
} )
.catch(e=>{
console.log(e)
})
网友评论