朱丽叶

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

统计

uni-app web-view不占满全屏·

// web-view
<web-view :src="pdfUrl"></web-view>

// 在onLoad中调用
// #ifdef APP-PLUS
  this.setWebviewHeight()
// #endif

// methods方法
setWebviewHeight() {
  // #ifdef APP-PLUS
  let height = 0; //定义动态的高度变量,如高度为定值,可以直接写
  uni.getSystemInfo({
    //成功获取的回调函数,返回值为系统信息
    success: sysinfo => {
      height = sysinfo.windowHeight - 47; //自行修改,自己需要的高度
    },
  });
  const currentWebview = this.$scope.$getAppWebview(); //获取当前web-view
  setTimeout(function() {
      const wv = currentWebview.children()[0];
      wv.setStyle({				
      top: 50, //设置web-view距离顶部的距离以及自己的高度,单位为px
      height: height
    });
  }, 1000); //如页面初始化调用需要写延迟
  // #endif
}

posted on   朱丽叶  阅读(1350)  评论(1编辑  收藏  举报

相关博文:
阅读排行:
· 【.NET】调用本地 Deepseek 模型
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
点击右上角即可分享
微信分享提示