问题:
当H5嵌套在web-view中,打包后的app打开后的页面的导航栏与手机状态栏重叠
根据官方文档:App端web-view的扩展
解决方案:
html
<template>
<view>
<web-view ref="webview" :src="path" @message="message" />
</view>
</template>
javascript
onLoad(e) {
const dateTime = new Date()
this.path = `https://xxxx.com/?t=${dateTime.getTime()}#/`
this.$nextTick(() => {
currentWebview = this.$scope.$getAppWebview()
setTimeout(function() {
var wv = currentWebview.children()[0]
wv.setStyle({// 设置web-view距离顶部的距离以及自己的高度,单位为px
top: 42 // 距离顶部的高度
bottom:0,//防止输入框被软键盘遮挡、防止底部tabbar被遮挡
// height:height,//webview的高度
})
}, 1000) // 如果是首页的onload调用时需要延时一下,二级页面无需延时,可直接获取
})
},