Vue中div高度自适应

<template>
  <div :style="conheight">
</template>
<script>
  export default{
    data(){
      conheight:{
                height:''
            }
    },
    methods:{
        getHeight(){
          this.conheight.height=window.innerHeight-170+'px';
       },
    created(){
        window.addEventListener('resize', this.getHeight);
        this.getHeight()
     }
  }
 
</script>

  

posted @ 2020-07-07 09:43  青竹玉简  阅读(7321)  评论(0编辑  收藏  举报