vue 报错Error in mounted hook: "SyntaxError: Unexpected token u in JSON at position 0"
程序员文章站
2022-07-12 11:37:38
...
今天写项目的时候突然发现项目报错 ,Error in mounted hook: "SyntaxError: Unexpected token u in JSON at position 0"
经过查找发现是深拷贝的函数影响的,可能拷贝的不是json,所以没办法解析,其实总的原因可能就是json数据格式不对引起的,仔细看控制台应该就可以找到。
/**
* 深拷贝
* @param obj
* @returns {any}
*/
export function deepClone (obj) {
let _obj = JSON.stringify(obj)
let objClone = JSON.parse(_obj)
return objClone
}
备注:假设B复制了A,当修改A时,如果B也跟着变了,说明这是浅拷贝,如果B没变,那就是深拷贝。
上一篇: makefile语法
下一篇: xilinx FPGA约束文件
推荐阅读
-
vue 报错Error in mounted hook: "SyntaxError: Unexpected token u in JSON at position 0"
-
报错: Error in created hook: “SyntaxError: Unexpected token u in JSON at position 0
-
flutter报错解决 Error: FormatException: SyntaxError: Unexpected token m in JSON at position 1
-
JSON字符格式报错:VM40:1 Uncaught SyntaxError: Unexpected token E in JSON at position 0
-
SyntaxError: Unexpected token R in JSON at position 0 报错的解决方法
-
报错 SyntaxError: Unexpected token R in JSON at position 0 at JSON.parse (<anonymous>)的解决方法
-
解决报错:Uncaught SyntaxError: Unexpected token “xxx” in JSON at position 0
-
解决报错信息之:SyntaxError: Unexpected token R in JSON at position 0
-
JS报错解决:SyntaxError: Unexpected token 《 in JSON at position 0
-
报错 Uncaught SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse