uniapp webview設(shè)置不全屏,設(shè)置自定義導(dǎo)航欄
使用webview時(shí)默認(rèn)填充整個(gè)屏幕的,這時(shí)候我們加個(gè)自己的導(dǎo)航欄被遮住出不來,所以我們需要自定義webview的高度,才能顯示出導(dǎo)航欄,傳入導(dǎo)航欄高度(單位px),調(diào)用下面方法即可
// 自定義webview高度 function setWebview(offset) { var height = 0; uni.getSystemInfo({ success: (sysinfo) => { height = sysinfo.windowHeight - offset; }, complete: () => {} }); var currentWebview = this.$scope.$getAppWebview(); //獲取當(dāng)前web-view setTimeout(function() { var wv = currentWebview.children()[0]; wv.setStyle({ top: offset, height }) }, 100); } setWebview(40) // 調(diào)用,假設(shè)導(dǎo)航欄高度為40,傳入40即可
掃描二維碼推送至手機(jī)訪問。
版權(quán)聲明:本文由星星博客發(fā)布,如需轉(zhuǎn)載請(qǐng)注明出處。