zoukankan      html  css  js  c++  java
  • vue监听浏览器高度

    <div id="TableConConStucke" :style="contentStyleObj">
        省去内容......
    </div>
    
    data中:
    contentStyleObj: {
            height: "",
            overflow: "auto"
    }
    
    methods中:
     getHeight() {
          // 获取浏览器高度  768 1080一般笔记本浏览器高度
          if (window.innerHeight < 768 || window.innerHeight < 1080) {
            this.contentStyleObj.height = "361px";
          } else {
            this.contentStyleObj.height = "auto";
          }
        },
    
    created中
    // 监听浏览器高度事件
        window.addEventListener("resize", this.getHeight);
        // 执行浏览器高度事件
        this.getHeight();
    
    destroyed中
    // 页面一关闭,销毁监听事件
        window.removeEventListener("resize", this.getHeight);
  • 相关阅读:
    文件路径与操作系统
    试验10
    shiyan9
    sql
    shiyan8
    iostream
    shiyan7
    CDMA
    试验6
    试验5
  • 原文地址:https://www.cnblogs.com/home-/p/12195808.html
Copyright © 2011-2022 走看看