当前位置:网站首页>递归检查配置项是否更变并替换
递归检查配置项是否更变并替换
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]
})
}
边栏推荐
- AI target segmentation capability for fast video cutout without green screen
- 罗德里格斯公式(Rodrigues‘ Rotation Formula)推导
- Oracle19c安装图文教程
- 【web】理解 Cookie 和 Session 机制
- 2022河南青训联赛第(三)场
- 最大层内元素和
- OC中new和init的区别
- ApiFox 基本使用教程(浅尝辄止,非广)
- 线程的不同状态
- AWR analysis report questions for help: How can SQL be optimized from what aspects?
猜你喜欢

Reflex WMS Intermediate Series 7: What should I do if I want to cancel the picking of an HD that has finished picking but has not yet been loaded?

Nanoprobes免疫测定丨FluoroNanogold试剂免疫染色方案

The principle and code implementation of intelligent follower robot in the actual combat of innovative projects

How to adjust the cross cursor too small, CAD dream drawing calculation skills

AWR analysis report questions for help: How can SQL be optimized from what aspects?

svm.SVC应用实践1--乳腺癌检测

AI target segmentation capability for fast video cutout without green screen

使用DBeaver进行mysql数据备份与恢复

2022-07-30 mysql8 executes slow SQL-Q17 analysis

BI - SQL 丨 WHILE
随机推荐
AWR analysis report questions for help: How can SQL be optimized from what aspects?
Reflex WMS Intermediate Series 7: What should I do if I want to cancel the picking of an HD that has finished picking but has not yet been loaded?
IMU预积分的简单理解
菜刀webshell特征分析
C#测试项目中属性的用法
使用DBeaver进行mysql数据备份与恢复
MySQL - CRUD operations
leetcode / anagram in string - some permutation of s1 string is a substring of s2
How to adjust the cross cursor too small, CAD dream drawing calculation skills
2022.8.1-----leetcode.1374
BioVendor Human Club Cellular Protein (CC16) Elisa Kit Research Fields
NIO‘s Sword(牛客多校赛)
使用self和_(下划线)的区别
四元数、罗德里格斯公式、欧拉角、旋转矩阵推导和资料
NAS和私有云盘的区别?1篇文章说清楚
2022年NPDP考完多久出成绩?怎么查询?
机器人领域期刊会议汇总
cadence landscape bindkey
The principle and code implementation of intelligent follower robot in the actual combat of innovative projects
Oracle19c安装图文教程