当前位置:网站首页>JS对象赋值问题
JS对象赋值问题
2022-07-26 10:35:00 【Suzerk】
Object.assign()
- 在使用element的过程中使用对象赋值
this.temp=this.listQuery在修改表格form中temp值的时候发现描述对象中的listQuery的数据一起改变。 - 最后发现,JS对象的赋值是默认引用赋值的。
查询相关资料,发现了可以使用Object.assign()解决
- 官方解释
Object.assign() 方法用于将所有可枚举属性的值从一个或多个源对象分配到目标对象。它将返回目标对象。
const target = {
a: 1, b: 2 };
const source = {
b: 4, c: 5 };
const returnedTarget = Object.assign(target, source);
console.log(target);
// expected output: Object {
a: 1, b: 4, c: 5 }
console.log(returnedTarget);
// expected output: Object {
a: 1, b: 4, c: 5 }
所以更改后this.temp = Object.assign({}, this.listQuery);这样就不会随之变化了。
边栏推荐
- The problem of large fluctuation of hx711 data
- Uninstall Meizu app store
- SuperMap IClient for Leaflet 加载高斯克吕格投影三度分带CGCS2000大地坐标系WMTS服务
- 404页面和路由钩子
- json-c库的简单使用——将json文件转换为struct.
- L2-005 set similarity (intersection of vector and set)
- Controller返回JSON数据
- 【论文下饭】Deep Mining External Imperfect Data for ChestX-ray Disease Screening
- [leetcode每日一题2021/2/13]448. 找到所有数组中消失的数字
- C语言回调函数
猜你喜欢

js 获得当前时间,时间与时间戳的转换
![[leetcode每日一题2021/2/13]448. 找到所有数组中消失的数字](/img/9b/624416fa6a408bf64ca5438273176b.png)
[leetcode每日一题2021/2/13]448. 找到所有数组中消失的数字

Centos8 (liunx) deploying WTM (asp.net 5) using PgSQL

uniapp使用简单方法signalR(仅用于web调试,无法打包app)

链式方法调用的事务问题剖析

GIS方法类期刊和论文的综述(Introduction)怎么写?

Okaleido生态核心权益OKA,尽在聚变Mining模式

Dry goods likeshop takeout order system is open source, 100% open source, no encryption

PLC overview
![[Halcon vision] morphological corrosion](/img/f9/f01dd3340824ff28c84cf7bb52882e.png)
[Halcon vision] morphological corrosion
随机推荐
父类对子类的引用(父类引用指向子类对象)
json_ object_ put: Assertion `jso->_ ref_ count > 0‘ failed. Aborted (core dumped)
[Halcon vision] affine transformation
12 复制对象时勿忘其每一个成分
[Halcon vision] threshold segmentation
移动端H5开发常用技巧总结
C language calculation date interval days
Tradingview 使用教程
json-c库的简单使用——将json文件转换为struct.
SuperMap IClient for Leaflet 加载高斯克吕格投影三度分带CGCS2000大地坐标系WMTS服务
mysql 进不去了怎么办
【机器学习小记】【风格迁移】deeplearning.ai course4 4th week programming(tensorflow2)
一些你不知道的 web API
Navicat15 MySQL (centos7) connected to local virtual machine
algorithm
centos8(liunx)部署WTM(ASP.NET 5)使用pgsql
[leetcode每日一题2021/5/8]1723. 完成所有工作的最短时间
常见的类(了解)
比较器(Comparable与Comparator接口)
json_object_put: Assertion `jso->_ref_count > 0‘ failed.Aborted (core dumped)