$store
是挂载在 Vue
实例上的(即Vue.prototype
)。
我们可以通过在Vue
对象的原型上添加store
属性来使得每一个Vue
的实例都可以访问store
属性。
// 引入Vue
import Vue from 'vue';
// 为Vue对象的原型添加
Vue.prototype.$store = store;
$store
是挂载在 Vue
实例上的(即Vue.prototype
)。
我们可以通过在Vue
对象的原型上添加store
属性来使得每一个Vue
的实例都可以访问store
属性。
// 引入Vue
import Vue from 'vue';
// 为Vue对象的原型添加
Vue.prototype.$store = store;