uniapp: webview全屏遮挡住状态栏的解决方案

<!-- 返回上一步 -->
<template>
    <view>
		<web-view :src="webviewStyles" @message="handleMessage"></web-view>
    </view>
</template>
<script>
    export default {
        data() {
            return {
                webviewStyles: [],
            }
        },
		onLoad: function (option) { 
			if(uni.getStorageSync('user')){
				this.webviewStyles = decodeURIComponent(option.url)+'?key='+uni.getStorageSync('user').last_login_time; 
			}else{
				this.webviewStyles = decodeURIComponent(option.url);
			}
			let height = 0; //定义动态的高度变量
			let statusbar = 0; // 动态状态栏高度
			uni.getSystemInfo({ // 获取当前设备的具体信息
				success: (sysinfo) => {
					statusbar = sysinfo.statusBarHeight;
					height = sysinfo.windowHeight;
				}
			});
			let currentWebview = this.$scope.$getAppWebview(); //获取当前web-view
			setTimeout(function() {
				var wv = currentWebview.children()[0];
				wv.setStyle({
					top: statusbar,
					height: height - statusbar, // 我们在这里把webview的高度调整一下
				})
			}, 200); //如页面初始化调用需要写延迟
 
		}
    }
</script>
<style>
</style>


评论