Commit a79026df authored by chenghong_tao's avatar chenghong_tao

fix echarts resize

parent 6be0b6e7
......@@ -4,7 +4,7 @@
</template>
<script setup>
import { computed, nextTick } from "vue";
import { computed, nextTick, onUnmounted } from "vue";
import MarkdownIt from "markdown-it";
import { init } from "echarts";
import markdownItPrism from "markdown-it-prism";
......@@ -60,6 +60,18 @@ md.use((md) => {
}
myChart.setOption(option);
// 监听窗口大小变化事件
const resizeHandler = () => {
myChart.resize();
};
window.addEventListener("resize", resizeHandler);
// 清理事件监听器
onUnmounted(() => {
window.removeEventListener("resize", resizeHandler);
});
} catch (error) {
console.error("Error rendering chart:", error);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment