(echarts)解决echarts图表适配窗口的大小
解决方法:
// 为窗口加上宽度变化事件,当宽高发生改变时,调用echarts的resize()方法,调整图表尺寸
window.addEventListener("resize", function () {myChart.resize();
});
示例:
<div id="sixdimData" style="height: 100vh;width: 100vw" /><script>
import * as echarts from "echarts";methods:{echarts() {var chartDom = document.getElementById("sixdimData");var myChart = echarts.init(chartDom);var option;option = {... };option && myChart.setOption(option);// 为窗口加上宽度变化事件,当宽高发生改变时,调用echarts的resize()方法,调整图表尺寸window.addEventListener("resize", function () {myChart.resize();});},
}
</script>
解决参考:
1.https://blog.csdn.net/weixin_43394840/article/details/130504035
2.https://blog.csdn.net/Jay_Auto/article/details/128346818