关于store._vm
来源:12-10 Vuex 初始化(9)

慕粉4283821
2021-01-15
老师 ,为什么要在store 上定义一个_vm实例, 只是为了做警告吗。
// use a Vue instance to store the state tree
// suppress warnings just in case the user has added
// some funky global mixins
const silent = Vue.config.silent
Vue.config.silent = true
store._vm = new Vue({
data: {
$$state: state
},
computed
})
Vue.config.silent = silent
// enable strict mode for new vm
if (store.strict) {
enableStrictMode(store)
}
写回答
1回答
-
这里主要是为了把 state 变成响应式吧,这样修改了 state 的数据,使用到的组件才能自动更新。
012021-01-16
相似问题
$store的挂载疑惑
回答 1
关于wrappedGetter
回答 1