1. manifest.json的plus節點里面配置
"plus": {
"statusbar": {"immersed": true},
2.代碼里面設置plusReady或者onload方法里面
window.onload=function(){ var immersed = 0; var ms=(/Html5Plus\/.+\s\(.*(Immersed\/(\d+\.?\d*).*)\)/gi).exec(navigator.userAgent); if(ms&&ms.length>=3){ // 當前環境為沉浸式狀態欄模式 immersed=parseFloat(ms[2]);// 獲取狀態欄的高度 } var t=document.getElementsByTagName("header")[0] t.style.paddingTop=immersed+'px'; t.style.height=immersed+44+'px'; }