当前位置:网站首页>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]
})
}
边栏推荐
猜你喜欢
随机推荐
MySQL - CRUD operations
KICAD 小封装拉线卡顿问题 解决方法
2022-08-01 Install mysql monitoring tool phhMyAdmin
【LeetCode】102.二叉树的层序遍历
微服务:微智能在软件系统的简述
Electronic Manufacturing Warehouse Barcode Management System Solution
考完PMP学什么?前方软考等着你~
2022牛客多校三_F G
1688API
【CNN记录】tensorflow slice和strided_slice
ofstream,ifstream,fstream read and write files
(一)Redis: 基于 Key-Value 的存储系统
Safety (1)
极大似然估计
FOFAHUB使用测试
指针数组和数组指针
AcWing 1285. 单词 题解(AC自动机)
Talking about the "horizontal, vertical and vertical" development trend of domestic ERP
29. 删除链表中重复的节点
Nanoprobes丨1-巯基-(三甘醇)甲醚功能化金纳米颗粒








