解决使用echarts 默认100px问题

在使用display: none;隐藏显示或tab切换显示时图表得到宽高都是100px问题

js:

在显示点击事件结束后重新绘制

Echarts
            .getInstanceById(
              document
                .getElementById("自己的容器ID")
                .getAttribute("_echarts_instance_")
            )
         }).resize();


VUE:

已经在vue的main.js 全局注入

import echarts from "echarts";
Vue.prototype.$echarts = echarts;

第一

      let echarts = this.$echarts;
      let myChart = echarts.init(document.getElementById(this.idName));
      myChart.setOption(this.optionData);
      //强制重新绘制
      this.$nextTick(() => {
        myChart.resize();
      });

第二

        let vm = this;
        this.$nextTick(() => {
          vm.$echarts
            .getInstanceById(
              document
                .getElementById("自己的容器ID")
                .getAttribute("_echarts_instance_")
            )
         });


本文作者:admin

本文链接:https://www.javalc.com/post/36.html

版权声明:本篇文章于2020-11-06,由admin发表,转载请注明出处:分享你我。如有疑问,请联系我们

winform 使用CefSharp + vue 实现前后端交互

发表评论

取消
扫码支持