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>

猜你喜欢

转载自www.cnblogs.com/Kyaya/p/10309148.html