zoukankan      html  css  js  c++  java
  • VUE.JS 窗口发生变化时,获取当前窗口的高度。

    VUE.JS

    # 窗口发生变化时,获取当前窗口的高度。

    方案一:

      mounted () {
        const that = this;
        window.onresize = () => {
          return (() => {
            that.screenHeight = window.innerHeight
          })()
        }
      },
      data(){
        return {
          screenHeight: window.innerHeight,
        }
      }

     方案二:

    export default {
       data(){
         return {
           screenHeight: window.innerHeight,
         }
       },
        mounted() {
            window.addEventListener('resize', this.onResize);
        },
        beforeDestroy() {
            window.removeEventListener("resize", this.onResize);
        },
        methods: {
            onResize() {
                this.screenHeight = window.innerHeight;
            }
        }
    }
  • 相关阅读:
    5.5,5.6
    5.1,5.2
    第四章.编程练习
    多源最短路径--flody算法
    Java 面试题
    python 打包exe程序
    sql优化
    二叉树
    todo: 队列、栈、散列集
    java注解
  • 原文地址:https://www.cnblogs.com/520future/p/9906313.html
Copyright © 2011-2022 走看看