我在Vuex中使用Vue.js,并想知道是否有一种方法可以像actions那样破坏getter?
这个吸气者:
doneTodosCount: (state, getters, rootState, rootGetters) => {
.....
}
变成这样的人:
doneTodosCount: ({rootGetters}) => {
.....
}
问这个问题,因为在第一个示例中,我不需要前三个参数状态、getters、rootState,但仍然需要编写它们才能到达第四个rootGetters
发布于 2019-06-20 05:19:05
您不能这样做,因为您没有破坏任何对象;您需要按照正确的顺序列出参数。
我想您可以编写一个忽略前3个参数的助手函数,但老实说,我认为它没有那么有用。
const f = fn => (state, getters, rootState, rootGetters) => fn(rootGetters)
export default {
doneTodosCount: f(rootGetters => {
...
})
}
https://stackoverflow.com/questions/56686729
复制相似问题