vue键盘抬起_vue移动端--键盘弹起(隐藏底部按钮)

基本思路是通过监听屏幕的高度来改变底部的显示/隐藏

首先:在data中获取屏幕的默认以及实时高度---->

data() {

return {

isShow:true,//按照标准隐藏

domHeight: document.documentElement.clientHeight, //默认屏幕高度

showHeight: document.documentElement.clientHeight, //实时屏幕高度

}

然后实现监听事件(监听高度变换从而改变isShow的值)

showHeight() {

if (this.domHeight > this.showHeight) {

this.hidshow = false;

} else {

this.hidshow = true;

}

}

最后再mounted(需要注意换取的哪里的高度)移动端建议是可见区域

document.body.clientWidth ==> BODY对象宽度

document.body.clientHeight ==> BODY对象高度

document.documentElement.clientWidth ==> 可见区域宽度

document.documentElement.clientHeight ==> 可见区域高度

window.onresize = () => {

return (() => {

this.showHeight = document.documenElement.clientHeight;//这里需要注意一下可视区高度。

})();

};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值