fix: 🐛 修复echart图表在keep-alive缓存下切换其他页面缩放后再返回页面不能自适应问题
This commit is contained in:
@@ -87,14 +87,23 @@ const options = {
|
||||
],
|
||||
};
|
||||
|
||||
const chart = ref<any>("");
|
||||
|
||||
onMounted(() => {
|
||||
const chart = echarts.init(
|
||||
document.getElementById(props.id) as HTMLDivElement
|
||||
chart.value = markRaw(
|
||||
echarts.init(document.getElementById(props.id) as HTMLDivElement)
|
||||
);
|
||||
chart.setOption(options);
|
||||
|
||||
chart.value.setOption(options);
|
||||
|
||||
window.addEventListener("resize", () => {
|
||||
chart.resize();
|
||||
chart.value.resize();
|
||||
});
|
||||
});
|
||||
|
||||
onActivated(() => {
|
||||
if (chart.value) {
|
||||
chart.value.resize();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user