vue 自适应页面高度

html 复制代码
<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>
相关推荐
vueTmp几秒前
个人开发者系列-上线即“爆火”?那些掏空你 Cloudflare 额度的虚假繁荣
前端·nuxt.js
i7i8i9com几秒前
React 19+Vite+TS学习基础-1
前端·学习·react.js
CHANG_THE_WORLD3 分钟前
switch case 二分搜索风格
前端·数据库
我的golang之路果然有问题3 分钟前
实习中遇到的 CORS 同源策略自己的理解分析
前端·javascript·vue·reactjs·同源策略·cors
Pony_186 分钟前
面试 - web ui 自动化
前端·ui·自动化
EndingCoder12 分钟前
接口基础:定义对象形状
linux·运维·前端·javascript·typescript
WebGISer_白茶乌龙桃15 分钟前
Vue3 + Mapbox 加载 SHP 转换的矢量瓦片 (Vector Tiles)
javascript·vue.js·arcgis·webgl
Pilot-HJQ26 分钟前
固定 Element UI 表格表头的方法(超简单)
vue.js·学习·css3·html5
passerma34 分钟前
解决qiankun框架子应用打包后css里的图片加载404失败问题
前端·微前端·qiankun
Aliex_git1 小时前
性能优化 - Vue 日常实践优化
前端·javascript·vue.js·笔记·学习·性能优化