可视化大屏适配方案一window.onresize监听窗口变化

    
<template>
  <div class="datav" ref="datav" />
</template>
export default{
mounted(){
    this.pageResize();

    window.onresize = () => {
      this.pageResize();
    };
}
}
  methods: {
    pageResize() {
      let windowWidth = document.body.clientWidth;
      if (windowWidth != 1920) {
        let scaleNum = Number.parseFloat((windowWidth / 1920).toFixed(3));
        if (windowWidth <= 1366) {
          scaleNum += 0.008;
        }
        this.$refs.datav.style = `transform-origin: 0 0 0;transform: scale(${scaleNum});`;
      }
    },
}

 

 
posted @ 2021-04-07 15:25  Jim-vue  阅读(336)  评论(0编辑  收藏  举报