首页 > 其他分享 >Antv/G6 画布自适应

Antv/G6 画布自适应

时间:2023-02-27 19:47:13浏览次数:44  
标签:G6 container graph Antv height 画布 width let

mounted () {
    window.addEventListener('resize', this.handleResize)    
}
    // 画布尺寸适配
    handleResize () {
      if (!this.graph || this.graph.get('destroyed')) return
      let container = document.getElementById('container')
      let height = container.offsetHeight
      let width = container.offsetWidth
      if (!width || !height) return
      this.graph.changeSize(width, height) // 接受两个参数(改变的宽度,高度)
    },

在用户拖拽浏览器改变大小时,使用 graph.changeSize

 

参考文章:AntV G6 的坑之—— fitView 适配失败

 

标签:G6,container,graph,Antv,height,画布,width,let
From: https://www.cnblogs.com/rachelch/p/17161616.html

相关文章