当前位置:网站首页>Recursively check if a configuration item has changed and replace it
Recursively check if a configuration item has changed and replace it
2022-08-02 02:45:00 【Xianyu_JavaScript】
介绍
- When the configuration item has the original configuration item,I don't want to change other configurations and can change the proposed configuration.参考 echarts 的配置
- 本文以递归的方式,实现了对象format check and replace,Arrays can be added according to the rules;
- The values that support the same attribute are based on the incoming attribute value;Properties that are not in the original configuration are added directly(当前级);
- According to the third point can be supported echarts、Secondary packaging configuration such as maps.
实现代码
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]
})
}
边栏推荐
- Electronic Manufacturing Warehouse Barcode Management System Solution
- 最大层内元素和
- 2022-08-01 mysql/stoonedb slow SQL-Q18 analysis
- 1688API
- CASE2023
- 使用self和_(下划线)的区别
- Safety (1)
- 记一个gorm初始化的坑
- The first time I wrote a programming interview question for Niu Ke: input a string and return the letter with the most occurrences of the string
- Flask入门学习教程
猜你喜欢
随机推荐
BI - SQL 丨 WHILE
指针数组和数组指针
OC中成员变量,实例变量和属性之间的区别和联系
【web】理解 Cookie 和 Session 机制
通用客户端架构
AcWing 1285. 单词 题解(AC自动机)
使用self和_(下划线)的区别
Docker-compose安装mysql
Outsourcing worked for three years, it was abolished...
[Unity entry plan] 2D Game Kit: A preliminary understanding of the composition of 2D games
IMU预积分的简单理解
第11章_数据库的设计规范
EFCore 反向工程
菜刀webshell特征分析
NIO‘s Sword(牛客多校赛)
IPFS部署及文件上传(golang)
789. 数的范围
51. 数字排列
OC和Swift语言的区别
Pinduoduo leverages the consumer expo to promote the upgrading of domestic agricultural products brands and keep pace with international high-quality agricultural products









