From dbfdc1166172e3cdc45b7093376cef83bea75fb9 Mon Sep 17 00:00:00 2001 From: zmc <zmc_li@foxmail.com> Date: 星期二, 08 八月 2023 08:56:46 +0800 Subject: [PATCH] 油烟监测 vue代码 --- src/sfc/DashboardChart.vue | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/sfc/DashboardChart.vue b/src/sfc/DashboardChart.vue index c9211af..a1d3b7d 100644 --- a/src/sfc/DashboardChart.vue +++ b/src/sfc/DashboardChart.vue @@ -1,6 +1,7 @@ <!-- 浠〃鐩樼粍浠� 鐖剁粍浠朵紶鍏ユ暟鎹簮涓巇ata缁戝畾鍚� 鑷姩娓叉煋 鐖剁粍浠舵渶濂藉惎鍔ㄥ紓姝ョ粍浠� + 鍝嶅簲寮忓彉鍖栧ぇ灏� --> <template> <div class="dashboard-item" ref="chartContainer"></div> @@ -47,6 +48,7 @@ mounted() { // 椤甸潰鍔犺浇瀹屾垚鍚庤皟鐢ㄤ华琛ㄧ洏 this.init() + window.addEventListener('resize',this.updateChart) }, methods:{ // 鍒濆鍖栦华琛ㄧ洏 @@ -74,19 +76,27 @@ } ] }); - } + }, + updateChart(){ + this.$nextTick(() => { + if (this.chart) { + this.chart.resize(); + } + }); + } }, beforeUnmount() { // 閿�姣佷华琛ㄧ洏瀹炰緥 this.chart.dispose(); - } + }, + }; </script> <style> .dashboard-item { - width: 400px; + width:100%; height: 300px; - margin: 10px; + /* margin: 10px; */ } </style> \ No newline at end of file -- Gitblit v1.9.3