小编在进行对象合并{....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)
检查对象是否支持拓展
console.log(Object.isExtensible(对象)) true为可,false为不可
解决办法
js
const c = {...a,...b} ---> a不可拓展
const ob = {...a} // 浅拷贝
const c = {...ob,...b}