1、需要 await 接收参数
async downApp() {
// await 接收参数 - 只能接收 return 的 promise(且是成功的resolve) 类型的参数
const url = await this.getUrl()
console.log(url.data)
},
getUrl() {
// 如果 await 需要接收 请求参数 , 那么 需要 return 一个 promise 的类型
return new Promise((resolve)=>{
axios({
method: 'get',
url: 'http://stationontrol/dviceInfo/queryComuncationState',
data: {}
})
.then((response)=>{
resolve(response)
})
.catch((error)=>{})
})
},
2、不需要接收参数 , 只需要 - 顺序执行 函数
async downApp() {
// await 让异步 变同步了
await this.getUrl()
await this.getUrl2()
},
getUrl() {
console.log('执行 函数1')
},
getUrl2() {
console.log('执行 函数2')
},