当前位置: 首页 > ops >正文

App使用webview套壳引入h5(二)—— app内访问h5,顶部被手机顶部菜单遮挡问题,保留顶部安全距离

引入webview的页面添加safeAreaInsets,对weview的webviewStyles做处理
在myApp中改造

entry.vue代码如下

template><view class="entry-page" :style="{ paddingTop: safeAreaInsets.top + 'px' }"><web-view :webview-styles="webviewStyles" :src="webviewUrl" @message="getH5Message" ref="webViewRef"></web-view></view>
</template><script>
export default {data() {return {statusBarHeight: 100,safeAreaInsets: {},webviewUrl: 'myLink', hasBottomSafeArea: false,webviewStyles: {progress: {color: '#007aff',top: 0},// iOS侧滑返回配置ios: {allowsBackForwardNavigationGestures: true, // 启用WKWebView侧滑手势bounces: false // 禁用弹性效果}},webview: '',isIOS: false,          // 判断是否为iOS设备webviewCanBack: false  // WebView是否可返回};},onLoad(options) {// #ifdef APP-PLUSthis.isIOS = uni.getSystemInfoSync().platform === 'ios'; // 检测iOS设备let _this = this;let height = 0;let statusbar = 0;const sysInfo = uni.getSystemInfoSync();this.safeAreaInsets = sysInfo.safeAreaInsets; //获取顶部安全距离console.log('top--------', sysInfo);this.statusBarHeight = sysInfo.statusBarHeight;height = sysInfo.windowHeight;let currentWebview = this.$scope.$getAppWebview();setTimeout(() => {var wv = currentWebview.children()[0];console.log('top--------222222222', _this.statusBarHeight);wv.setStyle({top: _this.statusBarHeight, //给weview设置顶部安全距离height: height - _this.statusBarHeight,scalable: false //禁止缩放}, 200);// #endif}
}
</script><style>
.entry-page {background-color: #f8f8f8;
}.webview-container {flex: 1;width: 100%;
}
</style>
http://www.xdnf.cn/news/12187.html

相关文章:

  • 两个错误教训记录--java变量作用域问题导致变量值异常
  • calico/node is not ready: BIRD is not ready: BGP not established with xxx
  • sumatraPDF设置深色界面
  • ArcGIS Maps SDK for JavaScript:使用图层过滤器只显示FeatureLayer的部分要素
  • LG P9990 [Ynoi Easy Round 2023] TEST_90 Solution
  • 风机下引线断点检测算法实现
  • 免费wordpress模板下载
  • Astro深度解析:颠覆传统的前端架构革命,打造极致性能的现代Web应用
  • KMP 算法中 next 数组的构建函数 get_next
  • linux-------------------------进程间通信(上)
  • QMetaObject::invokeMethod调用失败
  • 摄像机ISP处理流程
  • 【面经分享】京东
  • springboot实现查询学生
  • Spring @Scheduled vs XXL-JOB vs DolphinScheduler vs Airflow:任务调度框架全景对比
  • 电子电路:什么是扩散电容?
  • PC 360安全浏览器
  • Spring Boot + MyBatis 集成支付宝支付流程
  • Hive的Parquet格式优化方法
  • AI应用工程师面试
  • html+css+js趣味小游戏~MissileGame街机挑战(附源码)
  • Hive SQL常见操作
  • 人工智能--大型语言模型的存储
  • 窗口聚合窗口聚合
  • YOLOv11 | 注意力机制篇 | 混合局部通道注意力MLCA与C2PSA机制
  • 【photoshop】专色浓度和专色密度
  • Python[数据结构及算法 --- 栈]
  • Mobile App UI自动化locator
  • 【数据结构】树形结构--二叉树(二)
  • JavaSec-XSS