<template><view class="index"><u-navbar :is-back="true" title="标题"" :title-width="650"></u-navbar><web-view :src="webSrc"></web-view></view></template><script>export default {name: "index",data() {return {navHeight: 0, // 初始化 navHeightwebSrc: "",};},onLoad() {// #ifdef APP-PLUSvar that = this;var height = 0; // 定义动态的高度变量var statusBarHeight = 0;uni.getSystemInfo({// 成功获取的回调函数,返回值为系统信息success: (sysinfo) => {that.navHeight = 44; // 假设导航栏高度为 44px,你可以根据实际情况调整height =sysinfo.windowHeight - that.navHeight - sysinfo.statusBarHeight; // 自行修改,自己需要的高度statusBarHeight = sysinfo.statusBarHeight;},complete: () => {},});var currentWebview = this.$scope.$getAppWebview(); // 获取当前 web-viewsetTimeout(function () {var wv = currentWebview.children()[0];wv.setStyle({// 设置 web-view 距离顶部的距离以及自己的高度,单位为 pxtop: that.navHeight + statusBarHeight,height: height,});}, 500); // 如页面初始化调用需要写延迟// #endif}
};
</script>