Vue中div高度自适应

Vue中尽量不使用dom的高度计算

<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 @ 2019-01-23 15:17  lilyliu329  阅读(13734)  评论(1编辑  收藏  举报