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>
相关推荐
想你依然心痛27 分钟前
AtomCode 在前端开发中的实战体验:React + TypeScript 项目开发实录
前端·react.js·typescript
疯狂的魔鬼31 分钟前
精确计算容器剩余视口高度:useAutoContainerFullHeight 的工程实践
前端·css·typescript
Esaka_Forever36 分钟前
Python 与 JS (V8) 垃圾回收核心区别 + 底层根源分析
开发语言·javascript·jvm
用户0595401744638 分钟前
用了 3 个月 ChatGPT,才发现它一直在遗忘——用 Playwright 自动化验证记忆存储一致性
前端·css
玄玄子39 分钟前
xss前端解决方案
前端·浏览器·xss
林希_Rachel_傻希希41 分钟前
web性能优化之——AI总结视频
前端·javascript·面试
前端炒粉1 小时前
个人简历面经总结二
前端·网络·vue.js·react.js·面试
binbin_521 小时前
UIAbility 与 WindowStage:窗口创建、加载、销毁的完整链路
开发语言·javascript·深度学习·华为·harmonyos
用户059540174461 小时前
用了半年 LangChain Memory,才发现回滚测试压根没测对
前端·css
木木的木云1 小时前
从零构建微前端框架:PavilionMfe 设计揭秘
前端·架构·vite