Quellcode durchsuchen

销毁echarts再重新创建

dong vor 2 Monaten
Ursprung
Commit
bb6e9f6c4e
1 geänderte Dateien mit 22 neuen und 20 gelöschten Zeilen
  1. 22 20
      src/views/module_tpm/equipmentRunStatis/realtime.vue

+ 22 - 20
src/views/module_tpm/equipmentRunStatis/realtime.vue

@@ -212,25 +212,25 @@ export default {
         return
       }
       // 获取图表信息
-      getAction(_this.url.listparams, _this.queryParams).then((res) => {
-        if (res.success) {
-          console.log("listparams")
-          _this.equipmentparams = res.result.records || res.result;
-          getAction(_this.url.list, _this.queryParams).then((res) => {
-          console.log("list")
-            if (res.success) {
-            _this.mongodbdata = [];
-              _this.mongodbdata = res.result.records || res.result;
-              _this.initEcharts();
-            } else {
-              this.$message.warning(res.message)
-            }
-          });
-        } else {
-          this.$message.warning(res.message)
-        }
-      });
-      // this.getTest();
+      // getAction(_this.url.listparams, _this.queryParams).then((res) => {
+      //   if (res.success) {
+      //     console.log("listparams")
+      //     _this.equipmentparams = res.result.records || res.result;
+      //     getAction(_this.url.list, _this.queryParams).then((res) => {
+      //     console.log("list")
+      //       if (res.success) {
+      //       _this.mongodbdata = [];
+      //         _this.mongodbdata = res.result.records || res.result;
+      //         _this.initEcharts();
+      //       } else {
+      //         this.$message.warning(res.message)
+      //       }
+      //     });
+      //   } else {
+      //     this.$message.warning(res.message)
+      //   }
+      // });
+      this.getTest();
     },
     // 后端好了需要删掉
     getTest() {
@@ -242,7 +242,9 @@ export default {
       var _this = this
       var chartDom = this.$refs.trendCharts
 
-      _this.myChart.dispose();
+      if (_this.myChart != null && _this.myChart.dispose) {
+        _this.myChart.dispose(); // 销毁实例
+      }
       _this.myChart = echarts.init(chartDom)
       _this.echartsHeight = 4 * 300;
       // 获取time