当前位置:网站首页>Day 245/300 JS forEach 多层嵌套后数据无法更新到对象中
Day 245/300 JS forEach 多层嵌套后数据无法更新到对象中
2022-07-06 06:28:00 【Arden Zhao】
(一)需求
新增对象和编辑对象,对于业务场景下面的属性的值的默认值要区分,设置不同的默认值。
(二)实现
1、forEach 更新数据失败了
一开始尝试,是在获取异步请求后,直接进行数据处理的,但是失败了,在另一边选择不同的业务场景下,一直无法更新。
- 复杂对象数据的深拷贝,试过了不行
- nextTick到下微任务异步队列,试过了不行
- setTimeout到下个宏任务异步队列,试过了还行不行
心情略崩溃,就是不行;
2、进一步排查
发现是在选业务场景后,数据会有重新赋值的情况; 而选择重新赋值使用的旧有的对象。
虽然到现在还是不大明白,为什么,数据渲染后,还是没有渲染到原始的对象中,这里先记录下。之后再补充。
this.toolsList.forEach(function (item) {
item.checked= true
if (_this.newState) {
if (item.tool_name === 'other') {
const attributes = item.attributes
attributes.forEach((attr) => {
if (attr.name === 'edit_object_model') {
console.log('attr2', attr)
attr.value = '10'
}
})
}
}
})
写在最后的话
学习路上,常常会懈怠
《有想学技术需要监督的同学嘛~》
https://mp.weixin.qq.com/s/FyuddlwRY7DsHUejCjiVug
边栏推荐
- CS passed (cdn+ certificate) PowerShell online detailed version
- Basic knowledge of MySQL
- 模拟卷Leetcode【普通】1405. 最长快乐字符串
- sourceInsight中文乱码
- 私人云盘部署
- Phishing & filename inversion & Office remote template
- A 27-year-old without a diploma, wants to work hard on self-study programming, and has the opportunity to become a programmer?
- 模拟卷Leetcode【普通】1219. 黄金矿工
- CS-证书指纹修改
- An article was uncovered to test the truth of outsourcing companies
猜你喜欢
keil MDK中删除添加到watch1中的变量
Suspended else
org. activiti. bpmn. exceptions. XMLException: cvc-complex-type. 2.4. a: Invalid content beginning with element 'outgoing' was found
How to convert flv file to MP4 file? A simple solution
生物医学英文合同翻译,关于词汇翻译的特点
今日夏至 Today‘s summer solstice
Wish Dragon Boat Festival is happy
How effective is the Chinese-English translation of international economic and trade contracts
SQL Server manager studio(SSMS)安装教程
Cobalt Strike特征修改
随机推荐
Biomedical localization translation services
基于JEECG-BOOT的list页面的地址栏参数传递
[web security] nodejs prototype chain pollution analysis
Address bar parameter transmission of list page based on jeecg-boot
[mqtt from getting started to improving series | 01] quickly build an mqtt test environment from 0 to 1
Simulation volume leetcode [general] 1109 Flight reservation statistics
Thesis abstract translation, multilingual pure human translation
Simulation volume leetcode [general] 1414 The minimum number of Fibonacci numbers with a sum of K
JDBC requset corresponding content and function introduction
Redis core technology and basic architecture of actual combat: what does a key value database contain?
Transfert des paramètres de la barre d'adresse de la page de liste basée sur jeecg - boot
Simulation volume leetcode [general] 1447 Simplest fraction
Past and present lives of QR code and sorting out six test points
SSO流程分析
Full link voltage measurement: building three models
Oscp raven2 target penetration process
Py06 字典 映射 字典嵌套 键不存在测试 键排序
Fledgling Xiao Li's 103rd blog CC2530 resource introduction
Modify the list page on the basis of jeecg boot code generation (combined with customized components)
MFC on the conversion and display of long string unsigned char and CString