zoukankan      html  css  js  c++  java
  • vue---监听浏览器窗口的宽度

    使用VUE开发后台项目,后台项目需要进行后台根据浏览器窗口进行变化,需要使用vue来监听浏览器的窗口变化。

    <template>
        <div class="content" :style="height"></div>
    </template>
    
    <script>
    export default {
      name: 'App',
      data () {
      return {
          height:'',
      }
      },
      components:{},
      methods:{
        getHeight(){
          this.height = window.innerHeight - 70 + 'px';
        }
      },
      created(){
        window.addEventListener('resize', this.getHeight);
        this.getHeight()
      },
      destroyed(){
        window.removeEventListener('resize', this.getHeight)
      }
    }
    </script>
  • 相关阅读:
    Car HDU
    Defeat the Enemy UVALive
    Alice and Bob HDU
    Gone Fishing POJ
    Radar Installation POJ
    Supermarket POJ
    Moo Volume POJ
    Text Document Analysis CodeForces
    checkbox全选与反选

  • 原文地址:https://www.cnblogs.com/e0yu/p/10905148.html
Copyright © 2011-2022 走看看