宏任务微任务同步任务执行顺序以及使用async函数的值
async await 使用:
使用async函数的值
let data = this.getBusinessDetail(categoryId, true);
data.then(function(val) {
self.sealId = val.result.sealId || '';
self.sealName = val.result.sealName || '';
});
定义async函数
async getBusinessDetail(categoryId, initData) {
try {
const self = this;
let data = await this.axios({
url: '/category/' + categoryId,
method: 'get'
});
data = data.data;
this.sealPresence = !!data.result.sealId;
if (data.result && data.result.physicsConfig) {
this.nodes = data.result.physicsConfig.nodes;
let approvalProcessArr = this.nodes.filter(item => {
return item.assignSeal;
});
if (approvalProcessArr && approvalProcessArr[0].type !== 'START') {
this.approvalProcess = approvalProcessArr[0].name;
}
this.processShow = true;
} else {
this.nodes = [];
this.processShow = false;
}
if (!this.businessId) {
this.sealId = data.result.sealId;
this.sealName = data.result.sealName;
}
return data;
} catch (error) {
console.log(error);
}
},
js执行顺序:
https://juejin.im/post/59e85eebf265da430d571f89
async await promise执行顺序:https://zhuanlan.zhihu.com/p/52000508?utm_source=wechat_session&utm_medium=social&utm_oi=66091162271744
宏任务、微任务、执行顺序特别全:
首先先排出宏任务队列,然后执行第一个宏任务,执行宏任务里面的微任务,第一个宏任务了里面的微任务全部结束后执行第二个宏任务then里面执行的放在同步任务之后,同步任务就是
https://blog.csdn.net/weixin_42420703/article/details/82790942
finally用法