Skip to content

Commit 5fe5305

Browse files
committed
support store injection
1 parent d645bb9 commit 5fe5305

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ export { createLogger }
223223
// export install function
224224
export function install (_Vue) {
225225
Vue = _Vue
226+
const _init = Vue.prototype._init
227+
Vue.prototype._init = function (options) {
228+
options = options || {}
229+
if (options.store) {
230+
this.$store = options.store
231+
} else if (options.parent && options.parent.$store) {
232+
this.$store = options.parent.$store
233+
}
234+
_init.call(this, options)
235+
}
226236
}
227237

228238
// also export the default

0 commit comments

Comments
 (0)