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>
相关推荐
叫个啥呢43 分钟前
第一次写 DSH 插件:跟着自己的喜好实现个简单的代码管理插件
前端
掘金酱1 小时前
AI 带来的新生意|稀土掘金 X-Lab 年度大会招募开启
前端·后端·vibecoding
某哈压力大1 小时前
移动端 rem 适配
前端·vue.js·面试
洋洋技术笔记1 小时前
动态组件与异步组件
vue.js
泯泷1 小时前
Vercel AI SDK 6 完整教程系列 - 第一部分:基础入门篇
前端·javascript
lcy_241 小时前
10 万条数据滚动不卡?聊聊我写的虚拟列表组件 vue-virtualize
前端
zhanlang02172 小时前
HTML 零基础入门到企业实战【第七章 7.5】表单验证基础属性:required、maxlength、placeholder
前端·html
涛涛ing2 小时前
为了快 30 倍,我把构建工具换成了 Rust,结果团队差点连班都加不了
前端
parade岁月2 小时前
SolidJS 2.0 正式发布:异步成为响应式的一部分
前端