js中对象发生不可拓展问题

小编在进行对象合并{....a,....b}的时候发生了如下报错

报错如下

Uncaught runtime errors:

×

ERROR

Cannot assign to read only property 'password' of object '#'

TypeError: Cannot assign to read only property 'password' of object '#'

at createUser (http://localhost:3000/static/js/src_view_Registered_registered_js.chunk.js:43:19)

at submit (http://localhost:3000/src_view_Registered_registered_js.186aa687e8d666b41197.hot-update.js:51:79)

at onFinish (http://localhost:3000/static/js/vendors-node_modules_antd_es__util_colors_js-node_modules_antd_es_divider_index_js-node_modul-7e8d3b.chunk.js:8195:9)

at http://localhost:3000/static/js/vendors-node_modules_antd_es__util_colors_js-node_modules_antd_es_divider_index_js-node_modul-7e8d3b.chunk.js:9460:11

检查对象是否支持拓展

console.log(Object.isExtensible(对象)) true为可,false为不可

解决办法

js 复制代码
const c = {...a,...b} ---> a不可拓展
const ob = {...a} // 浅拷贝
const c = {...ob,...b}
相关推荐
草莓火锅15 小时前
用c++使输入的数字各个位上数字反转得到一个新数
开发语言·c++·算法
Sunlightʊə15 小时前
2.登录页测试用例
运维·服务器·前端·功能测试·单元测试
j_xxx404_15 小时前
C++ STL:阅读list源码|list类模拟|优化构造|优化const迭代器|优化迭代器模板|附源码
开发语言·c++
DreamNotOver15 小时前
批量转换论文正文引用为上标
开发语言·论文上标
散峰而望15 小时前
C/C++输入输出初级(一) (算法竞赛)
c语言·开发语言·c++·算法·github
fie888915 小时前
基于MATLAB的狼群算法实现
开发语言·算法·matlab
gihigo199815 小时前
MATLAB中生成混淆矩阵
开发语言·matlab·矩阵
Code Crafter16 小时前
ES6-ES14 新特性速查
前端·ecmascript·es6
Lhuu(重开版16 小时前
CSS从0到1
前端·css·tensorflow
曾几何时`16 小时前
C++——this指针
开发语言·c++