vue 自适应页面高度

<template>
  <div :style="{height: this.winHeight + 'px'}">
	<div :style="{height: this.winHeight * 0.3 + 'px'}"></div>
	<div :style="{height: this.winHeight * 0.3 + 'px'}"></div>
	<div>底部的 div 会自适应高度</div>
  </div>
</template>

<script>
export default {
      
      
  data () {
      
      
    return {
      
      
      winHeight: 0,
    }
  }
  created() {
      
      
	this.getHeight()
  },
  methods: {
      
      
	getHeight () {
      
      
      const winHeight = window.innerHeight
      // this.winHeight = winHeight - tabs 高度 这段可选
      console.log('winHeight', this.winHeight)
    },
  }
};
</script>

猜你喜欢

转载自blog.csdn.net/m0_54355172/article/details/133776109