in Promise, no matter where the resolve is, is it always executed last? Who can talk about the operating mechanism, or share a link. Thank you! the
code is as follows:
actions.getForbiddenFuncList = function(context){
return new Promise((resolve, reject) => {
serverUtils.getData(serverUtils.GETFORBIDDENFUNCLIST,null,(resData)=>{
if(resData.success){
resolve();
console.log("1")
context.commit("SETFORBIDEENFUNCLIST", resData)
console.log("2")
console.log("3")
}
});
})
}
mutations.SETFORBIDEENFUNCLIST = function (state, data) {
console.log("SETFORBIDEENFUNCLIST, 1");
// ,.....
console.log("SETFORBIDEENFUNCLIST, 2");
}
actions.initData = function(context,payload) {
actions.loadControl(context,{ show: true });
serverUtils.getData(serverUtils.GETBYID,{id: payload.id},function(data) {
if (data.success) {
actions.getForbiddenFuncList(context).then(() => {
console.log("a")
context.commit("INITDATA", data.data);
console.log("b")
actions.getQuestionData(context,data.data.questionUrl);
actions.checkSliceUpdate(context,payload);
});
}
});
}
run result: