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>

  

最新文章

  1. python3爬取网页
  2. Java学习第三天160818 表单 框架 下拉列表等
  3. 原生javascript里jsonp的实现原理
  4. ofbiz进击 。 ofbiz 退货流程(包含获取可退货项流程分析 以及 取消退货项的过程分析)
  5. nandflash操作详解
  6. AccessHelper类
  7. [Canvas] Make Canvas Responsive to Pixel Ratio
  8. ubuntu12.04 U盘自动挂载配置
  9. SwingConsole
  10. Java后端程序员都做些什么?
  11. Python中 sys.argv[]的用法简明解释
  12. python常用工具组件
  13. 利用Git进行团队协作
  14. zookeeper安装和dubbo-admin使用
  15. python实现atm机基本操作及购物车
  16. Oracle学习笔记:decode函数
  17. 推荐2本学习java书和PDF
  18. 你远比想象中强大pdf
  19. 开始学习NodeJs, javascript, 算法
  20. Tomcat反带和集群

热门文章

  1. label标签的可访问性
  2. iphone 在设置了initial-scale=1 之后,在设置滚动条之后,没有滑动效果的解决办法
  3. [转载]文件过滤驱动 文件系统激活通知 IoRegisterFsRegistrationChange函数实现
  4. 任务29:自己动手构建RequestDelegate管道
  5. adb logcat 查看日志 (转载)
  6. 洛谷 - P2181 - 对角线 - 打表 - 组合数学
  7. 鸟哥私房菜基础篇:Linux 磁碟与档案系统管理习题
  8. CF767E ChangeFree【贪心/优先队列】By cellur925
  9. pycharm 断点调试
  10. selenium之webdriverAPI接口详解