在vuex动作中,我需要等待其他几个动作(所有promise)的结果。我想避免嵌套调度,有没有一种方法可以通过Promise.all来完成?例如:
Promise.all([ action1, action2 ])
.then(() => {
// do the thing
});
答案 0 :(得分:1)
如果您的操作返回“承诺”-是的,您可以这样做。 例如
['Plot',
'Early_years',
'Voldemort_returns',
'Supplementary_works',
'Harry_Potter_and_the_Cursed_Child',
'In-universe_books',
'Pottermore_website',
'Structure_and_genre',
'Themes',
'Origins',
'Publishing_history',
'Translations',
'Completion_of_the_series',
'Cover_art',
'Achievements',
'Cultural_impact',
'Commercial_success',
'Awards,_honours,_and_recognition',
'Reception',
'Literary_criticism',
'Social_impact',
'Controversies',
'Adaptations',
'Films',
'Spin-off_prequels',
'Games',
'Audiobooks',
'Stage_production',
'Attractions',
'The_Wizarding_World_of_Harry_Potter',
'The_Making_of_Harry_Potter',
'References',
'Further_reading',
'External_links']