美文网首页
echart图表自适应

echart图表自适应

作者: 七號7777 | 来源:发表于2020-06-18 10:44 被阅读0次

    参考文章:https://blog.csdn.net/qq_29541333/article/details/93640190

    data () {
        return {
          resizeTimer: null, // 监听屏幕变化的定时器
          chartObj: {
            mapAddress: null // 图
          }
        }
      },
    mounted() { 
      // 屏幕大小变化 
        let _this = this;
        window.addEventListener('resize', function () { 
          if (_this.resizeTimer) clearTimeout(_this.resizeTimer);
          _this.resizeTimer = setTimeout(function () {
            _this.chartObj.mapAddress.resize()
          }, 100)
        })
    },
    methods: { 
        // 画图的方法
        drawMap(div) {
            var myChart = echarts.init(document.getElementById(mapDiv));
            this.chartObj.mapAddress = myChart
            .........
        }
    }
    

    相关文章

      网友评论

          本文标题:echart图表自适应

          本文链接:https://www.haomeiwen.com/subject/coyntktx.html