关于 vuex 报错 Do not mutate vuex store state outside mutation handlers.

10 :问题描述

在使用vuex 时,有时候 我们在mutation中定义好方法,在页面或组件提交时

有可能经常会遇到这个错误:---->>Do not mutate vuex store state outside mutation handlers.

9. 原因:

The reason is that arrays are stored as references in Javascript and payload.items is likely to be changed outside Vuex. So we should just use a fresh copy of payload.itemsinstead.

8:解决方法 如下图

7:不建议使用Json.parse ,因为慢
时间: 2024-07-31 22:21:39

关于 vuex 报错 Do not mutate vuex store state outside mutation handlers.的相关文章

VUEX报错 [vuex] Do not mutate vuex store state outside mutation handlers

数组 错误的写法:let listData= state.playList; // 数组深拷贝,VUEX就报错 正确的写法:let listDate= state.playList.slice(); /*不能直接操作state里面的属性,但是可以创建一个副本*/ 对象 错误的写法:let listData= state.playList; // 对象深拷贝,VUEX就报错 正确的写法:let listDate= Object.assign({}, state.playList); /*不能直接操

使用vuex报错“__WEBPACK_IMPORTED_MODULE_1_vuex__.a.store is not a constructor”

import Vue from 'vue'; import Vuex from 'vuex'; Vue.use(Vuex); const store = new Vuex.store({ state:{ num:"我是vuex1" } }); export default store; 控制台显示报错 Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_1_vuex__.a.store is not a constructor (是因为尝试将不是

sqlplus连接数据库报错SP2-0642: SQL*Plus internal error state 2130, context 0:0:0解决

sqlplus连接数据库报错SP2-0642: SQL*Plus internal error state 2130, context 0:0:0解决 sqlplus 连接数据库报错SP2-0642: SQL*Plus internal error state 2130, context 0:0:0 问题描述: 使用sqlplus客户端登录数据库,报错SP2-0642,而使用其它方式plsql或者tnsnames等方式连接数据库均没有问题 [plain] [[email protected] ~

vuex 报错 hook.flushStoreModules is not a function 偶发性

最近开发项目 用到vuex, 刷新页面后偶发性的报错  hook.flushStoreModules is not a function 但是不影响页面任何功能和vuex的使用 进行了各种尝试仍然不行, 当前开发环境 "vue": "^2.5.2" "vuex": "^3.1.2" vue-cli:2.9.6 解决中.......... 原文地址:https://www.cnblogs.com/wangweizhang/p/1

ehcache报错ERROR n.s.e.store.disk.DiskStorageFactory - Disk Write的解决办法

23:53:44 ERROR n.s.e.store.disk.DiskStorageFactory - Disk Write of com.koal.**.**.**.**.**.***Impl$$EnhancerBySpringCGLIB$$5b782dcf.query****.2063333947 failed: java.io.NotSerializableException: com.koal.**.**.entity.**.helloDO 看图很明显,其中问题就是helloDO没有序

踩坑记录-nuxt引入vuex报错store/index.js should export a method that returns a Vuex instance.

错误 store/index.js代码如下: import Vue from 'vue'; import Vuex from 'vuex'; import city from './moudle/city' Vue.use(Vuex); //构造store const store = new Vuex.Store({ // 模块化 modules: { city: city } }); export default store; 解决办法 根据错误提示,到处一个方法,并在方法里把store导出.

Android录制视频报错setVideoSize called in a invalid state 1

录制视频时想获取手机支持的录制视频的分辨率,使用代码如下: List<Camera.Size> videoSize = camera.getParameters().getSupportedVideoSizes(); Iterator<Camera.Size> itos = videoSize.iterator(); while (itos.hasNext()) { Camera.Size curSize = itos.next(); int curSupporSize = cur

vue报错集锦

1.vue报错: 没安装 less-loader css-loader style-loader      可能的很大原因:没安装less 2.vuex报错:Computed property "xxx" was assigned to but it has no setter 在使用了vuex的情况下,state时导入的state,在页面中不能直接更改state的值,需要在mutation方法中更改,然后在vue组件中commit该方法 3.iview报错:iview出现col栅格提

vue在IE11报错‘vuex requires a Promise polyfill in this browser.’

报错信息 因为使用了 ES6 中用来传递异步消息的的Promise,而IE浏览器都不支持.(vuex使用了ES6语法) npm install babel-polyfill(安装babel-polyfill) Babel是一个广泛使用的转码器,可以将ES6代码转为ES5代码,从而可以在现有环境执行.所以你可以用ES6编写,而不用考虑环境支持的问题. 修改方法1: 在 Webpack中使用 修改方法2: 在main.js中使用 import"babel-polyfill"; import