当前位置:网站首页>递归检查配置项是否更变并替换
递归检查配置项是否更变并替换
2022-08-02 02:39:00 【闲鱼_JavaScript】
介绍
- 配置项有原有配置项的情况下,又不想变动其他的配置又能更改提出来配置。参考 echarts 的配置
- 本文以递归的方式,实现了对象格式检查并替换,数组的话可以跟着规则添加就行;
- 支持相同属性的值以传入的属性值为主;在原配置没有的属性则直接加进去(当前级);
- 根据第三点可以支持 echarts、地图等二次封装配置。
实现代码
const configSet = (config, eCData = echartsComponent.data) => {
if (!config) return;
Object.keys(eCData).forEach(key => {
if (!(key in config)) return
if (Object.prototype.toString.call(config[key]) === '[object Object]') return configSet(config[key], eCData[key])
eCData[key] = config[key]
})
Object.keys(config).forEach(key => {
if (!(key in eCData)) eCData[key] = config[key]
})
}
边栏推荐
猜你喜欢

2022-07-30 mysql8执行慢SQL-Q17分析

字符串常用方法

Nanoprobes多组氨酸 (His-) 标签标记:重组蛋白检测方案

网络层解析——IP协议、地址管理、路由选择

指针数组和数组指针

Talking about the "horizontal, vertical and vertical" development trend of domestic ERP

国标GB28181协议EasyGBS平台兼容老版本收流端口的功能实现

BI-SQL丨WHILE

Nanoprobes Polyhistidine (His-) Tag: Recombinant Protein Detection Protocol

2022-08-01 mysql/stoonedb慢SQL-Q18分析
随机推荐
Swift运行时(派发机制)
The failure to create a role in Dahua Westward Journey has been solved
列表常用方法
yaml
1688API
790. 数的三次方根
项目场景 with ERRTYPE = cudaError CUDA failure 999 unknown error
AI target segmentation capability for fast video cutout without green screen
Chapter 7 Noise analysis
isa指针使用详情
TKU remembers a single-point QPS optimization (I wish ITEYE is finally back)
MySQL - CRUD operations
Nanoprobes丨1-巯基-(三甘醇)甲醚功能化金纳米颗粒
罗德里格斯公式(Rodrigues‘ Rotation Formula)推导
analog IC layout
Service discovery of kubernetes
2022牛客多校三_F G
Safety (1)
简单的页面跳转活动
OperatingSystemMXBean获取系统性能指标