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