问题描述
在逐渐了解vuex
之后,我目前正在与vue
一起玩。所以我开始用veux
我可以在单击添加后添加待办事项,但是我确实想在完成后清除input
。我有两个商店模块。
一个名为todo_inputs
的人是todos
,因此,当单击add
时,会从addItem
模块调用一个操作{{1 }}
提交完成后,我想清除todos
中setTodos
的输入,但不知何故无法到达。
我阅读了一些https://vuex.vuejs.org/guide/modules.html#accessing-global-assets-in-namespaced-modules
的stackoverflow和vuex文档很多人都在说使用诸如'commit('todo_input / setInputText',null {root:true})之类的命名空间,但这还是行不通的...
此外,如果在模块内部放入state
,则在设置此设置后,我的其他动作几乎会中断。
这些是我的商店模块
todo_input.js
todo_input
todos.js
{namespace: true}
store / index.js
const state = {
item: null
};
const getters = {
getInputText: ({ item }) => item
};
const actions = {
onInput({ commit },e) {
commit("setInputText",e.target.value);
}
};
const mutations = {
setInputText: (state,item) => {
state.item = item;
}
};
export default {
namespaced: true,// I tried adding this here which breaks my other action such as oninput()
state,getters,actions,mutations
};
我读了几篇文章,很多人在说使用命名空间,虽然看起来很明显,但是我在这里做错了什么?
在此先感谢您的帮助/建议。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)