Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript vuex中的[Vue.js]名称空间_Javascript_Vue.js_Vuex - Fatal编程技术网

Javascript vuex中的[Vue.js]名称空间

Javascript vuex中的[Vue.js]名称空间,javascript,vue.js,vuex,Javascript,Vue.js,Vuex,我试图命名模块的getter、突变、action,我看到了这一点,但它似乎有点模糊 //types.js //将getter、操作和突变的名称定义为常量 //它们的前缀是模块名“todos”` 导出const DONE_COUNT='todos/DONE_COUNT' export const FETCH_ALL='todos/FETCH_ALL' export const TOGGLE_DONE='todos/TOGGLE_DONE' //模块/todos.js 从“../types”导入*

我试图命名模块的getter、突变、action,我看到了这一点,但它似乎有点模糊

//types.js
//将getter、操作和突变的名称定义为常量
//它们的前缀是模块名“todos”`
导出const DONE_COUNT='todos/DONE_COUNT'
export const FETCH_ALL='todos/FETCH_ALL'
export const TOGGLE_DONE='todos/TOGGLE_DONE'
//模块/todos.js
从“../types”导入*作为类型
//使用前缀名称定义getter、action和transformation
常数todosModule={
国家:{todos:[]},
吸气剂:{
[类型.完成计数](状态){
// ...
}
},
行动:{
[types.FETCH_ALL](上下文,有效负载){
// ...
}
},
突变:{
[types.TOGGLE_DONE](状态,有效负载){
// ...
}
}

}
通过在“vuex”中使用MapGetter解决了此问题
this.$store.getters['todos/DONE_COUNT']