소스 검색

support store injection

Evan You 9 년 전
부모
커밋
5fe5305b89
1개의 변경된 파일10개의 추가작업 그리고 0개의 파일을 삭제
  1. 10 0
      src/index.js

+ 10 - 0
src/index.js

@@ -223,6 +223,16 @@ export { createLogger }
 // export install function
 export function install (_Vue) {
   Vue = _Vue
+  const _init = Vue.prototype._init
+  Vue.prototype._init = function (options) {
+    options = options || {}
+    if (options.store) {
+      this.$store = options.store
+    } else if (options.parent && options.parent.$store) {
+      this.$store = options.parent.$store
+    }
+    _init.call(this, options)
+  }
 }
 
 // also export the default