我正在尝试命名模块的getter,mutgest,actions,我看到这个document here,但它看起来有点模糊。
sig Person {father: Person}
fact {
no p: Person | p in p.^father
}
assert Every_Person_Has_A_Father {
all p: Person | some p.father
}
check Every_Person_Has_A_Father
然后我如何使用模块化的getter,vue组件中的突变?
// types.js
// define names of getters, actions and mutations as constants
// and they are prefixed by the module name `todos`
export const DONE_COUNT = 'todos/DONE_COUNT'
export const FETCH_ALL = 'todos/FETCH_ALL'
export const TOGGLE_DONE = 'todos/TOGGLE_DONE'
// modules/todos.js
import * as types from '../types'
// define getters, actions and mutations using prefixed names
const todosModule = {
state: { todos: [] },
getters: {
[types.DONE_COUNT] (state) {
// ...
}
},
actions: {
[types.FETCH_ALL] (context, payload) {
// ...
}
},
mutations: {
[types.TOGGLE_DONE] (state, payload) {
// ...
}
}
}
答案 0 :(得分:3)
this.$store.getters['todos/DONE_COUNT']