erp-el-element/utils/autoTableHeight.js

34 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-05-07 11:51:58 +08:00
/*
* @Author: your name
* @Date: 2021-05-06 17:17:43
* @LastEditTime: 2021-06-29 17:27:21
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \aiguo_erp_vue\src\utils\autoTableHeight.js
*/
//获取浏览器窗口高度,处理Element的Table组件的高度问题height只能是数字或者字符串
function autoTableHeight() {
var winHeight = 0;
if (window.innerHeight) {
winHeight = window.innerHeight;
} else if (document.body && document.body.clientHeight) {
winHeight = document.body.clientHeight;
} //通过深入Document内部对body进行检测获取浏览器窗口高度
if (document.documentElement && document.documentElement.clientHeight) {
winHeight = document.documentElement.clientHeight;
}
// 370 是顶部和底部导航以及部分自定义布局 相当于用js实现了 height: calc(100vh - 260px); 的效果
return winHeight - 370;
}
//浏览器窗口变化时
window.onresize = function() {
autoTableHeight();
};
//浏览器重新加载时
window.onload = function() {
autoTableHeight();
};
export default autoTableHeight;