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>
相关推荐
lxh0113几秒前
数据流的中位数
开发语言·前端·javascript
神仙别闹6 分钟前
基于NodeJS+Vue+MySQL实现一个在线编程笔试平台
前端·vue.js·mysql
zadyd1 小时前
Workflow or ReAct ?
前端·react.js·前端框架
北寻北爱3 小时前
vue2和vue3使用less和scss
前端·less·scss
IT_陈寒3 小时前
Redis性能提升3倍的5个冷门技巧,90%开发者都不知道!
前端·人工智能·后端
雨雨雨雨雨别下啦4 小时前
Vue案例——面经
前端·javascript·vue.js
oo121384 小时前
里程碑5 - 完成框架 npm 包抽象封装并发布
前端·npm
达拉4 小时前
我花了三天用AI写了个上一代前端构建工具
前端·前端工程化
bysking4 小时前
【31-Ai-Agent】ai-agent的核心实现细节-bysking
前端
从文处安4 小时前
「前端何去何从」(React教程)React 状态管理:从局部 State 到可扩展架构
前端·react.js