Skip to content

Commit 852ac43

Browse files
ktsnyyx990803
authored andcommitted
fix: move auto installation code into the store constructor (#914)
1 parent be15f32 commit 852ac43

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/store.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ let Vue // bind on install
77

88
export class Store {
99
constructor (options = {}) {
10+
// Auto install if it is not done yet and `window` has `Vue`.
11+
// To allow users to avoid auto-installation in some cases,
12+
// this code should be placed here. See #731
13+
if (!Vue && typeof window !== 'undefined' && window.Vue) {
14+
install(window.Vue)
15+
}
16+
1017
if (process.env.NODE_ENV !== 'production') {
1118
assert(Vue, `must call Vue.use(Vuex) before creating a store instance.`)
1219
assert(typeof Promise !== 'undefined', `vuex requires a Promise polyfill in this browser.`)
@@ -463,8 +470,3 @@ export function install (_Vue) {
463470
Vue = _Vue
464471
applyMixin(Vue)
465472
}
466-
467-
// auto install in dist mode
468-
if (typeof window !== 'undefined' && window.Vue) {
469-
install(window.Vue)
470-
}

0 commit comments

Comments
 (0)