瀏覽代碼

fix: 优化G2组件的动态配置赋值,对于属性路径,将不存在的属性赋值空对象处理

hong.yang 1 年之前
父節點
當前提交
7dfb749f2c
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      data-room-ui/packages/PlotRender/index.vue

+ 6 - 0
data-room-ui/packages/PlotRender/index.vue

@@ -147,7 +147,9 @@ export default {
       let option = null
       config.setting.forEach(set => {
         if (set.optionField) {
+          // 例 point.style.fill
           const optionField = set.optionField.split('.')
+          // 例 [point,style,fill]
           option = config.option
           optionField.forEach((field, index) => {
             if (index === optionField.length - 1) {
@@ -156,6 +158,10 @@ export default {
                 option[field] = set.value
               }
             } else {
+              // 如果没有这个属性,则创建该属性,并赋值为空对值
+              if (!option[field]) {
+                option[field] = {}
+              }
               option = option[field]
             }
           })