vue 控制台报错 Uncaught (in promise) Error: “ *“ is read-only
程序员文章站
2022-05-30 16:39:21
...
chunk-569cd37e.4a478d0f.js:1 Uncaught (in promise) Error: "lastPoint" is read-only
at i (chunk-569cd37e.4a478d0f.js:1)
at chunk-569cd37e.4a478d0f.js:1
原代码为:
const lastPoint = {}
if (this.resData != null && this.resData.length > 0) {
lastPoint = this.resData[this.resData.length - 1]
}
修改为:
let lastPoint = {}
if (this.resData != null && this.resData.length > 0) {
lastPoint = this.resData[this.resData.length - 1]
}
原因:
const声明一个只读的常量。一旦声明,常量的值就不能改变。
let是块级作用域,函数内部使用let定义后,对函数外部无影响。
上一篇: webpack打包vue项目实战入门
推荐阅读
-
vue报错Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDup
-
VUE 登录不上,F12报错Uncaught (in promise) Error: Request failed with status code 404
-
报错 commons.js:8 Uncaught (in promise) Error: {}
-
vue 控制台报错 Uncaught (in promise) Error: “ *“ is read-only
-
vue使用axios报404错误:Uncaught (in promise) Error: Request failed with status code 404
-
vue使用axios报404错误:Uncaught (in promise) Error: Request failed with status code 404