hookehuyr

fix IE注册页面高度遮挡问题

<!--
* @Date: 2024-10-18 17:57:33
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-10-22 17:57:02
* @LastEditTime: 2024-10-24 18:11:00
* @FilePath: /hager/src/views/user/index.vue
* @Description: 文件描述
-->
......@@ -44,14 +44,24 @@ export default {
// 设置用户盒子高度
// 监听窗口的 resize 事件
window.addEventListener('resize', this.handleHeight);
// 判断是否被遮挡,让屏幕能滚动
if (!this.isElementInViewport('#router-view')) { // #router-view 被屏幕遮挡
$('.hager-user-page').css('height', 'auto')
} else {
$('.hager-user-page').css('height', '100vh')
this.overflowScroll();
},
watch: {
'$route.path' (to, from) { // 路由变化
this.overflowScroll();
}
},
methods: {
overflowScroll () {
this.$nextTick(() => {
// 判断是否被遮挡,让屏幕能滚动
if (!this.isElementInViewport('#router-view')) { // #router-view 被屏幕遮挡
$('.hager-user-page').css('height', 'auto')
} else {
$('.hager-user-page').css('height', '100vh')
}
})
},
handleHeight () {
//
// if ($('#router-view').outerHeight() > $('.user-box').height()) {
......@@ -60,12 +70,7 @@ export default {
if ($('#router-view').outerHeight() < $('.user-box').height()) {
$('#router-view').height($('.user-box').outerHeight())
}
// 判断是否被遮挡,让屏幕能滚动
if (!this.isElementInViewport('#router-view')) { // #router-view 被屏幕遮挡
$('.hager-user-page').css('height', 'auto')
} else {
$('.hager-user-page').css('height', '100vh')
}
this.overflowScroll();
},
isElementInViewport(element) {
var rect = $(element)[0].getBoundingClientRect(); // 获取元素相对于视口的大小和位置
......