Преглед на файлове

fix: move auto installation code into the store constructor (#914)

katashin преди 7 години
родител
ревизия
852ac43ea4
променени са 1 файла, в които са добавени 7 реда и са изтрити 5 реда
  1. 7 5
      src/store.js

+ 7 - 5
src/store.js

@@ -7,6 +7,13 @@ let Vue // bind on install
 
 export class Store {
   constructor (options = {}) {
+    // Auto install if it is not done yet and `window` has `Vue`.
+    // To allow users to avoid auto-installation in some cases,
+    // this code should be placed here. See #731
+    if (!Vue && typeof window !== 'undefined' && window.Vue) {
+      install(window.Vue)
+    }
+
     if (process.env.NODE_ENV !== 'production') {
       assert(Vue, `must call Vue.use(Vuex) before creating a store instance.`)
       assert(typeof Promise !== 'undefined', `vuex requires a Promise polyfill in this browser.`)
@@ -463,8 +470,3 @@ export function install (_Vue) {
   Vue = _Vue
   applyMixin(Vue)
 }
-
-// auto install in dist mode
-if (typeof window !== 'undefined' && window.Vue) {
-  install(window.Vue)
-}