autoHeight.vue 高度自适应
2024-08-26 07:37:37
autoHeight.vue 高度自适应
<!--
* @description 自适应高度
* @fileName autoHeight.vue
* @author 彭成刚
* @date 2019/03/11 09:45:38
* @version V1.0.0
<autoHeight v-model="s1Height"
:allHeight='0'
:precent='20'
:diffHeight='0'>
<table-s1 :height="s1Height"></table-s1>
</autoHeight>
!-->
<template>
<div :style='styleHeight'>
<slot></slot>
</div>
</template> <script>
export default {
data () {
return {
allHeightData: 0,
styleHeight: ''
}
},
props: {
value: {
type: Number,
default: 0
},
noStyle: {
type: Boolean,
default: false
},
allHeight: {
type: Number,
default: 0
},
precent: {
type: Number,
default: 100
},
diffHeight: {
type: Number,
default: 0
}
}, components: {}, computed: {}, mounted () {
this.calcHeight()
window.addEventListener('resize', () => {
this.calcHeight()
})
// window.innerHeight
},
watch: {
'allHeight' (to, from) {
this.calcHeight()
},
'$route' (to, from) {
this.calcHeight()
}
},
methods: {
calcHeight () {
let retHeight
if (this.allHeight === 0) {
this.allHeightData = window.innerHeight
} else {
this.allHeightData = this.allHeight
} retHeight = (this.allHeightData * this.precent / 100) - this.diffHeight
this.$emit('input', retHeight) if (!this.noStyle) {
this.styleHeight = 'height: ' + retHeight + 'px; overflow-y:auto;'
}
} }
} </script>
<style lang='less' scoped>
</style>
最新文章
- python3爬取网页
- Java学习第三天160818 表单 框架 下拉列表等
- 原生javascript里jsonp的实现原理
- ofbiz进击 。 ofbiz 退货流程(包含获取可退货项流程分析 以及 取消退货项的过程分析)
- nandflash操作详解
- AccessHelper类
- [Canvas] Make Canvas Responsive to Pixel Ratio
- ubuntu12.04 U盘自动挂载配置
- SwingConsole
- Java后端程序员都做些什么?
- Python中 sys.argv[]的用法简明解释
- python常用工具组件
- 利用Git进行团队协作
- zookeeper安装和dubbo-admin使用
- python实现atm机基本操作及购物车
- Oracle学习笔记:decode函数
- 推荐2本学习java书和PDF
- 你远比想象中强大pdf
- 开始学习NodeJs, javascript, 算法
- Tomcat反带和集群
热门文章
- label标签的可访问性
- iphone 在设置了initial-scale=1 之后,在设置滚动条之后,没有滑动效果的解决办法
- [转载]文件过滤驱动 文件系统激活通知 IoRegisterFsRegistrationChange函数实现
- 任务29:自己动手构建RequestDelegate管道
- adb logcat 查看日志 (转载)
- 洛谷 - P2181 - 对角线 - 打表 - 组合数学
- 鸟哥私房菜基础篇:Linux 磁碟与档案系统管理习题
- CF767E ChangeFree【贪心/优先队列】By cellur925
- pycharm 断点调试
- selenium之webdriverAPI接口详解