mounted() {
this.getData()
},
methods:{
// async 定义一个异步函数 getData()
// await 同步执行函数1,函数2
async getData(){
let data = this.axios.post('1').then(res=>{
if(res.code == 200){
console.log(res)
return res.data.id;//返回id,供下个接口使用
}
})
await this.axios.post('2',{
id:data
}).then(res=>{
if(res.code == 200){
console.log(res)
return res.data.id;//返回id
}
})
},
}
async、await简单使用
猜你喜欢
转载自blog.csdn.net/qq_40745143/article/details/106002419
今日推荐
周排行