Skip to content

Commit 6c1e48a

Browse files
committed
support 1.x as well
1 parent b25b4d4 commit 6c1e48a

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/override.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
import { getWatcher, getDep } from './util'
22

33
export default function (Vue) {
4-
Vue.mixin({ init })
4+
var version = Number(Vue.version.split('.')[0])
5+
6+
if (version >= 2) {
7+
Vue.mixin({
8+
init: vuexInit
9+
})
10+
} else {
11+
// override init and inject vuex init procedure
12+
// for 1.x backwards compatibility.
13+
const _init = Vue.prototype._init
14+
Vue.prototype._init = function (options = {}) {
15+
options.init = options.init
16+
? [vuexInit].concat(options.init)
17+
: vuexInit
18+
_init.call(this, options)
19+
}
20+
}
521

622
/**
723
* Vuex init hook, injected into each instances init hooks list.
824
*/
925

10-
function init () {
26+
function vuexInit () {
1127
const options = this.$options
1228
const { store, vuex } = options
1329
// store injection

0 commit comments

Comments
 (0)