File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { getWatcher , getDep } from './util'
2
2
3
3
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
+ }
5
21
6
22
/**
7
23
* Vuex init hook, injected into each instances init hooks list.
8
24
*/
9
25
10
- function init ( ) {
26
+ function vuexInit ( ) {
11
27
const options = this . $options
12
28
const { store, vuex } = options
13
29
// store injection
You can’t perform that action at this time.
0 commit comments