解决vue中echarts图自适应问题,设置100%宽度显示100px.


data(){ myChart:null, echarts_option1:{}, }, methods:{ setEcharts() { let myChart = document.getElementById("myChart"); myChart.style.width = window.innerWidth - 290 + "px"; //初始化echarts图表宽度 this.myChart = this.$echarts.init(myChart); this.myChart.setOption(this.echarts_option1); let self = this; window.addEventListener("resize", () => { // 通过resize方法来重设图表宽度 let myChart = document.getElementById("myChart"); myChart.style.width = window.innerWidth - 290 + "px"; self.myChart.resize(); }); }, mounted() { this.setEcharts(); },

 

你可能感兴趣的:(解决vue中echarts图自适应问题,设置100%宽度显示100px.)