原创

MUI-动态检测底部虚拟按键隐藏显示-监听虚拟按键

底部固定布局设置一个div position:absolute,bottom:0px
<!--用于监听底部虚拟按键开启和关闭-->
<div id="idFixedButtom" style="background-color: red; position: absolute;bottom: 0px;width: 100%;height:1px;">
</div>
<!--用于监听底部虚拟按键开启和关闭-->

mui-scroll-wrapper 好像还是要设置默认的绝对布局 style="position: absolute;

window.onresize = function() {
resizeScrollHeight();
}

function resizeScrollHeight() {
/**
* 子webview环境中,不需要考虑标题栏高度
*/
var partHeader = findID('partHeader');
var partHeaderHeight = partHeader.offsetHeight;
var clientHeight = window.screen.availHeight;//考虑到兼容性,只用这个获取屏幕高度
var idFixedButtom = findID('idFixedButtom');
var buttomTop = idFixedButtom.offsetTop;
var buttomHeight = idFixedButtom.offsetHeight;
clientHeight = buttomTop;//核心这里灵活取高度值
var scrollHeight = clientHeight -buttomHeight;//在子webview环境中,不需要考虑标题栏高度
console.log('滚动区域 高度 计算 =' + scrollHeight);
var partScroll = findID('partScroll');
partScroll.style.height = scrollHeight +"px"; //必须加px
}


正文到此结束
本文目录