<div id="chartmainbar3"></div>
mounted(){
this.resizeEcharts = () => {
this.$echarts.init(document.getElementById("chartmainbar3")).resize();
}
window.addEventListener("resize", this.resizeEcharts);
}
媒体查询,设置图的宽高,不然刷新会出现空白(因为不设置高的话,刷新canvas图的height变为0,因此会出现界面空白不加载图的情况),所以需要在自适应的同时媒体查询设置宽高。
@media screen and (min-width: 200px) and (max-width: 1600px){
#chartmainbar3{
width: 100%!important;
height:260px!important;
margin-top: 3.7%
}
}
@media screen and (min-width: 1601px){
#chartmainbar3{
width: 100%!important;
height:360px!important;
margin-top: 3.7%
}
}