示例:
this.themes.basic = {
background: "black",
specialThings: {
border: "1px
}
}
this.themeObj: {
background: "black",
specialThings: {}
}
我需要一个扫描this.themeObj并替换缺失值的函数 具有this.themes.basic的值。它还应扫描该对象的子对象。 PS:请尽量不要使用eval
谢谢
答案 0 :(得分:-1)
您可以尝试:
let themes = {
background: "black",
specialThings: {
border: "1px"
}
}
let themeObj = {
background: "black",
specialThings: {}
}
const object3 = {...themeObj, ...themes };