mutation中修改state中的状态值,却报[vuex] do not mutate vuex store state outside mutation handlers.

网上百度说是在mutation外修改state中的状态值,会报下列错误,可我明明在mutations中修改的状态值,还是报错

mutation中修改state中的状态值,却报[vuex] do not mutate vuex store state outside mutation handlers.mutation中修改state中的状态值,却报[vuex] do not mutate vuex store state outside mutation handlers.接着百度,看到和我类似的问题,说mutations中只能用同步代码,异步用actions,我试着把修改值放在请求外面,结果不报错了mutation中修改state中的状态值,却报[vuex] do not mutate vuex store state outside mutation handlers.
参考:https://segmentfault.com/q/1010000011524218/


来自为知笔记(Wiz)

上一篇:vuex 之 概念和作用解析


下一篇:vue系列教程-15vuex的使用