uni-app web-view 如果设置不全屏 不自动铺满

官网地址:  https://uniapp.dcloud.io/component/web-view.html#web-view

web-view 是一个 web 浏览器组件,可以用来承载网页的容器,会自动铺满整个页面(nvue 使用需要手动指定宽高)。

  <web-view :src="pdfUrl" update-title="false"></web-view>
1 var currentWebview = this.$scope.$getAppWebview();//获取当前web-view  此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
2 setTimeout(function() {
3 var wv = currentWebview.children()[0];
4 console.log(wv);
5 wv.setStyle({//设置web-view距离顶部的距离以及自己的高度,单位为px
6 top: 68,
7 height:height
8 })
9 }, 1000);//如页面初始化调用需要写延迟

 

 

posted @ 2022-05-17 14:51  蓝色精灵jah  阅读(3773)  评论(0编辑  收藏  举报