From 013ed9283200da41902835f9fd679df13299d436 Mon Sep 17 00:00:00 2001 From: zmc <zmc_li@foxmail.com> Date: 星期四, 31 八月 2023 12:53:53 +0800 Subject: [PATCH] 扬尘Vue --- src/sfc/DustLineChart.vue | 31 ++++++++++++++++++------------- 1 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/sfc/DustLineChart.vue b/src/sfc/DustLineChart.vue index 99ec58e..4f2880e 100644 --- a/src/sfc/DustLineChart.vue +++ b/src/sfc/DustLineChart.vue @@ -5,7 +5,10 @@ --> <template> - <div id="main" class="line-chart"></div> + + <div id="main" class="line-chart-exception"></div> + + </template> <script> @@ -38,8 +41,6 @@ }, watch: { option(){ - // this.chart.dispose; - // this.initChart(); // this.chart.clear // 涓嶄笌涔嬪墠鐨刼ption杩涜鍚堝苟 this.chart.setOption(this.option,true) @@ -48,11 +49,11 @@ window.addEventListener('resize', this.resizeChart); }, }, - beforeUnmount() { - if (this.chart) { - this.chart.dispose; - } - }, + // beforeUnmount() { + // if (this.chart) { + // this.chart.dispose; + // } + // }, methods: { initChart() { // 鍒涘缓echarts瀹炰緥 @@ -98,19 +99,23 @@ // 璺熼〉闈㈠搷搴斿紡鍙樺寲 resizeChart() { - this.chart.resize(); + this.$nextTick(() => { + if (this.chart) { + this.chart.resize(); + } + }); } } }; </script> - <style> - .line-chart { - width:920px; + <style scoped> + .line-chart-exception { + width: 700px; height: 250px; margin-bottom: 20px; - min-width: 600px; + min-width: 500px; } </style> \ No newline at end of file -- Gitblit v1.9.3