当前位置:网站首页>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
边栏推荐
- mysql按照首字母排序
- 如何做好互联网金融的英语翻译
- Private cloud disk deployment
- 女生学软件测试难不难 入门门槛低,学起来还是比较简单的
- How much is the price for the seal of the certificate
- [mqtt from getting started to improving series | 01] quickly build an mqtt test environment from 0 to 1
- 記一個基於JEECG-BOOT的比較複雜的增删改功能的實現
- 模拟卷Leetcode【普通】1414. 和为 K 的最少斐波那契数字数目
- PHP uses redis to implement distributed locks
- 钓鱼&文件名反转&office远程模板
猜你喜欢
Cobalt Strike特征修改
Changes in the number of words in English papers translated into Chinese
私人云盘部署
Full link voltage measurement: building three models
SQL Server manager studio(SSMS)安装教程
記一個基於JEECG-BOOT的比較複雜的增删改功能的實現
MySQL5.72.msi安装失败
Use shortcut LNK online CS
翻译影视剧字幕,这些特点务必要了解
In English translation of papers, how to do a good translation?
随机推荐
Basic knowledge of MySQL
Py06 字典 映射 字典嵌套 键不存在测试 键排序
Biomedical English contract translation, characteristics of Vocabulary Translation
Simulation volume leetcode [general] 1143 Longest common subsequence
模拟卷Leetcode【普通】1249. 移除无效的括号
记一个基于JEECG-BOOT的比较复杂的增删改功能的实现
ECS accessKey key disclosure and utilization
我的创作纪念日
电子书-CHM-上线CS
Technology sharing | common interface protocol analysis
Simulation volume leetcode [general] 1447 Simplest fraction
The whole process realizes the single sign on function and the solution of "canceltoken" of undefined when the request is canceled
SQL Server manager studio(SSMS)安装教程
如何将flv文件转为mp4文件?一个简单的解决办法
基于JEECG-BOOT的list页面的地址栏参数传递
SSO流程分析
国产游戏国际化离不开专业的翻译公司
云服务器 AccessKey 密钥泄露利用
Changes in the number of words in English papers translated into Chinese
JDBC requset corresponding content and function introduction