webview在android下默认就是全屏状态,ios 刘海屏下则上下有白色留白,需要做特殊处理才能全屏。
具体代码如下:
vue文件的onload()中加入如下代码:
1 2 3 4 5 6 7 8 9 10 |
let pages = getCurrentPages(); //getCurrentPages() 函数用于获取当前页面栈的实例 let page = pages[pages.length - 1]; let currentWebview = page.$getAppWebview(); //$getAppWebview() 可以得到当前webview的对象实例,从而实现对 webview 更强大的控制。 if (uni.getSystemInfoSync().platform === 'ios') { setTimeout(function() { let wv = currentWebview.children()[0]; wv.setStyle({ contentAdjust: false, top: -1, bottom: -1, width: '100vw', height: '100vh' }); }, 100); } |
然后在 pages.json中添加如下配置:
1 2 3 4 5 6 7 8 9 |
{ "path": *****, "style": { "app-plus": { "contentAdjust":false } } }, |