axios等待同步请求

axios等待同步请求

methods: {
getLightList() {
let that = this;
return new Promise((resolve, reject) => {
that.query.type = '0';// 灯光
getLightList(this.query).then(res => {
that.lightList = res.data.data;
resolve(res.data.data)
});
})
},
async getCrossList () {
let that = this;
let lightList = await this.getLightList();
this.query.type = '1';// 能耗
getLightList(this.query).then(res => {
that.crossList = res.data.data;
console.log(lightList.length)
console.log(that.crossList.length)
});
}

posted @ 2020-12-25 15:30  GraceYang  阅读(519)  评论(0)    收藏  举报