安卓H5页面fixed布局被软键盘上顶问题

该博客介绍了如何使用Vue.js监听窗口大小变化,动态调整页面元素的显示状态。通过设置`isTabbar`变量控制固定内容的显示与隐藏,根据`docmHeight`和`showHeight`实时判断屏幕高度,实现页面适配。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Vue

data:{
			isTabbar: true, //判断页面的fixed内容是展示还是隐藏
 			docmHeight: document.documentElement.clientHeight,  //默认屏幕高度
            showHeight: document.documentElement.clientHeight,   //实时屏幕高度
},
 mounted() {
            // window.onresize监听页面高度的变化
            window.onresize = () => {
                return (() => {
                    this.showHeight = document.documentElement.clientHeight;
                })()
            }

        },
        watch: {
            showHeight() {
                if (this.docmHeight > this.showHeight) {
                    this.isTabbar = false
                } else {
                    this.isTabbar = true
                }
            }
        },
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值