getters 什么时候放到store.getters里面的?只看到读取的时候
来源:12-6 Vuex 初始化(5)

旋涡鸣人_
2019-03-11
function makeLocalGetters (store, namespace) {
const gettersProxy = {}
const splitPos = namespace.length
Object.keys(store.getters).forEach(type => {
// skip if the target getter is not match this namespace
if (type.slice(0, splitPos) !== namespace) return
// extract local getter type
const localType = type.slice(splitPos)
// Add a port to the getters proxy.
// Define as getter property because
// we do not want to evaluate the getters in this time.
Object.defineProperty(gettersProxy, localType, {
get: () => store.getters[type],
enumerable: true
})
})
return gettersProxy
}
Object.keys(store.getters)
store.getters 啥时候包含那么多东西?
写回答
1回答
-
使用的时候啊,你在实例化 Store 的时候,不就传进去了么
012019-03-11
相似问题