問(wèn)題
<web-view>如果設(shè)了"navigationStyle" : "custom"會(huì)自動(dòng)充滿全部屏幕,現(xiàn)在,如果想在頁(yè)面上面騰出statusBar高度,該怎么做?
不可行方案
CSS方案全部不可行。
可行方案
不要使用
<web-view>標(biāo)簽,而是使用JS編程方式。必須使用APP-PLUS。
<template>
<view>
</view>
</template>
script:
export default {
onLoad() {
// #ifdef APP-PLUS
var wv = plus.webview.create("http://xxx", "custom-webview", {
plusrequire: "none", //禁止遠(yuǎn)程網(wǎng)頁(yè)使用plus的API,有些使用mui制作的網(wǎng)頁(yè)可能會(huì)監(jiān)聽(tīng)plus.key,造成關(guān)閉頁(yè)面混亂,可以通過(guò)這種方式禁止
'uni-app': 'none', //不加載uni-app渲染層框架,避免樣式?jīng)_突
top: uni.getSystemInfoSync().statusBarHeight ,//放置在titleNView下方。如果還想在webview上方加個(gè)地址欄的什么的,可以繼續(xù)降低TOP值
height: uni.getSystemInfoSync().screenHeight - uni.getSystemInfoSync().statusBarHeight
})
var currentWebview = this.$scope.$getAppWebview(); //此對(duì)象相當(dāng)于html5plus里的plus.webview.currentWebview()。在uni-app里vue頁(yè)面直接使用plus.webview.currentWebview()無(wú)效,非v3編譯模式使用this.$mp.page.$getAppWebview()
currentWebview.append(wv); //一定要append到當(dāng)前的頁(yè)面里!?。〔拍芨S當(dāng)前頁(yè)面一起做動(dòng)畫,一起關(guān)閉
// #endif
}
}