1、在页面中加入ref
<div class="echart_income" ref="echartsWaring"></div>
2、去掉echarts渲染出来的属性_echarts_instance_
initChart() {//移除图表中_echarts_instance_属性this.$refs.echartsWaring.removeAttribute('_echarts_instance_')let getchart = echarts.init(this.$refs.echartsWaring);getchart.setOption(lineOption);//随着屏幕大小调节图表window.addEventListener("resize", () => {getchart.resize();});},
另外一种情况,当点击切换tab时echarts图表缩小在一起(宽高只有100px)的解决方法
在点击tab切换时添加事件
handleClick(){this.$nextTick(()=>{window.dispatchEvent(new Event("resize"));})},