Browse Source

compat with vue@2.0.0-alpha.7

Evan You 9 years ago
parent
commit
881ebb6cb1
2 changed files with 4 additions and 5 deletions
  1. 1 1
      package.json
  2. 3 4
      src/override.js

+ 1 - 1
package.json

@@ -56,7 +56,7 @@
     "sinon-chai": "^2.8.0",
     "todomvc-app-css": "^2.0.3",
     "uglify-js": "^2.6.2",
-    "vue": "^2.0.0-alpha.5",
+    "vue": "^2.0.0-alpha.7",
     "vue-loader": "^9.0.3",
     "webpack": "^1.12.8",
     "webpack-dev-server": "^1.12.1"

+ 3 - 4
src/override.js

@@ -1,12 +1,11 @@
 import { getWatcher, getDep } from './util'
 
 export default function (Vue) {
-  var version = Number(Vue.version.split('.')[0])
+  const version = Number(Vue.version.split('.')[0])
 
   if (version >= 2) {
-    Vue.mixin({
-      init: vuexInit
-    })
+    const usesInit = Vue.config._lifecycleHooks.indexOf('init') > -1
+    Vue.mixin(usesInit ? { init: vuexInit } : { beforeCreate: vuexInit })
   } else {
     // override init and inject vuex init procedure
     // for 1.x backwards compatibility.