問題描述項目基于vue + vuex在vuex中有一個多層嵌套請求函數,想要獲得中間某一層的返回值相關代碼const store = new Vuex.Store({actions:{
main(context, payload){
childA().then(() => {
...
childB().then(() => {
... if(payload == "planA"){
get().then(result => { //do something //我想要這里有一個返回值return
return "A";
});
}
});
});
}
}});想要在實例中獲得返回值,但沒有成功//index.vueexport default {mounted:function(){ this.main('planA');
},methods:{ async main(status){ let statcode = await this.$store.dispatch('main',status); console.log(statcode) //undefind,期待返回一個'A'
}
}}自己也覺得代碼問題不小,但翻了一些資料還沒找到解決辦法……請大佬指導學習一下
如何獲得多層嵌套剪頭函數的返回值?
慕碼人8056858
2019-03-07 12:11:46
