问题:
当H5嵌套在web-view中,打包后的app打开后的页面的导航栏与手机状态栏重叠
根据官方文档:App端web-view的扩展
解决方案:

<template>
  <view>
    <web-view ref="webview" :src="path" @message="message" />
  </view>
</template>
 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调用时需要延时一下,二级页面无需延时,可直接获取
    })
  },
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐