浏览代码

feat: 对于系统组件,添加对是否拥有customStyle方法的判断,如果组件没有此方法,则在加载的时候不执行customStyle方法

wu.jian2 1 年之前
父节点
当前提交
cc54aa6b1d
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      data-room-ui/packages/RemoteComponents/index.vue

+ 6 - 1
data-room-ui/packages/RemoteComponents/index.vue

@@ -199,7 +199,12 @@ export default {
         this.chart.update(config.option)
       }
       this.changeChartConfig(config)
-      this.$refs['remoteComponent' + config.code]?.customStyle(config)
+      // 在this.$refs['remoteComponent' + config.code]这个实例里判断是否存在customStyle方法,如果存在则执行
+      const componentInstance = this.$refs['remoteComponent' + config.code]
+      if (componentInstance && componentInstance.$options.methods && componentInstance.$options.methods.customStyle) {
+        // 调用 customStyle 方法
+        this.$refs['remoteComponent' + config.code]?.customStyle(config)
+      }
       return config
     },
     // 同步配置