Vuejs致力于突变失败(Vuejs commit to a mutation fails)

编程入门 行业动态 更新时间:2024-10-27 17:17:59
Vuejs致力于突变失败(Vuejs commit to a mutation fails)

这是我如何执行提交,但数据永远不会传递

const actions ={ updateBtn({commit}, data){ commit("test", data); console.log("data is"+data);//data here has a value } } const mutations={ test(state, {data}){ console.log(data) //this is always undefined. } }

我在哪里突然出错了

This is how am performing commit but data is never passed through

const actions ={ updateBtn({commit}, data){ commit("test", data); console.log("data is"+data);//data here has a value } } const mutations={ test(state, {data}){ console.log(data) //this is always undefined. } }

Where am i going wrong in the mutations

最满意答案

尝试不使用函数参数这样使用。

const actions = { updateBtn({commit}, data){ commit("test", data); console.log("data is"+data);//data here has a value } } const mutations = { test(state, data) { console.log(data); state.data = data; } }

Try using like this without function parameter.

const actions = { updateBtn({commit}, data){ commit("test", data); console.log("data is"+data);//data here has a value } } const mutations = { test(state, data) { console.log(data); state.data = data; } }

更多推荐

本文发布于:2023-07-28 22:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1309786.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:突变   致力于   Vuejs   fails   mutation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!