說說 Vuex 的 actions 屬性

Vuex 的 action 屬性內,可以定義異步操作邏輯,以滿足某些業務場景要求。在組件內,是通過 $store.dispatch 來觸發 action 定義的函數。 我們使用 action,來爲計數器異步增 1。 1 Promise 方式 main.js: const store = new Vuex.Store({ state: { count: 0, },
相關文章
相關標籤/搜索