瀏覽代碼

feat(store): bind mutation and action handlers to store (#872)

Pooya Parsa 7 年之前
父節點
當前提交
67da622555
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/store.js

+ 2 - 2
src/store.js

@@ -373,14 +373,14 @@ function makeLocalGetters (store, namespace) {
 function registerMutation (store, type, handler, local) {
   const entry = store._mutations[type] || (store._mutations[type] = [])
   entry.push(function wrappedMutationHandler (payload) {
-    handler(local.state, payload)
+    handler.call(store, local.state, payload)
   })
 }
 
 function registerAction (store, type, handler, local) {
   const entry = store._actions[type] || (store._actions[type] = [])
   entry.push(function wrappedActionHandler (payload, cb) {
-    let res = handler({
+    let res = handler.call(store, {
       dispatch: local.dispatch,
       commit: local.commit,
       getters: local.getters,