因为把 store 对象提供给vue实例的 store 选项后,可以把 store 的实例注入所有的子组件。具体到实现代码可以看 https://github.com/vuejs/vuex... 通过Vue.mixin({ beforeCreate: vuexInit })把vuexInit这个函数在所有子组件beforeCreate钩子执行,函数内改变组件this.$store指向 store实例
因为把 store 对象提供给vue实例的
store
选项后,可以把store
的实例注入所有的子组件。具体到实现代码可以看 https://github.com/vuejs/vuex...
通过
Vue.mixin({ beforeCreate: vuexInit })
把vuexInit
这个函数在所有子组件beforeCreate
钩子执行,函数内改变组件this.$store
指向store
实例