【发布时间】:2021-05-19 20:32:51
【问题描述】:
我正在使用 Nuxt fetch() lifecycle hook 从 Vuex 获取数据。我的商店结构如下所示
store/
--| index.js
--| dialog.js
--| country/
------| actions.js // I want to use async call in this file
------| getters.js
------| mutations.js
------| state.js
在我的组件中,我正在使用这样的 fetch
async fetch({ store }){
await store.dispatch("country/fetchCountries")
},
我的国家/actions.js 文件如下所示
export const fetchCountries = ({commit, dispatch}, form) => {
// let response = await this.$axios.get('/countries');
}
现在,我不能在函数前面使用 async。这个函数前面怎么用async?
【问题讨论】:
标签: javascript vue.js nuxt.js vuex