uni-app LivePusher高度不能撑满100%,在新版本Hbuilder中出现的问题。

uni-app LivePusher高度不能撑满100%,在新版本Hbuilder中出现的问题。

开发环境 版本号 项目创建方式
HBuilderX 3.1.22 云端
产品分类:HTML5+

手机系统:Android  
手机系统版本号:Android 8.1  
手机厂商:魅族  
手机机型:魅族  

打包方式:云端  

示例代码:
```html
<div class="pusher" id="pusher"></div>  
pusher = new plus.video.LivePusher('pusher', {
mode: 'FHD',
muted: true,
'auto-focus': localStorage.autoFocus == 'false'? false : true,
aspect: aspect < 0.5 ? '' : '9:16'
})
pusher.preview()

操作步骤: 如上代码创建LivePusher

预期结果: LivePusher默认宽高为100%

实际结果: LivePusher高度没有撑满webview

bug描述: LivePusher高度无法撑满屏幕,hbuilder更新后出现的。ios没问题,安卓3.1.18版本没问题,但是云打包有问题。


更多关于uni-app LivePusher高度不能撑满100%,在新版本Hbuilder中出现的问题。的实战教程也可以访问 https://www.itying.com/category-93-b0.html

2 回复

官方说下个版本修复

更多关于uni-app LivePusher高度不能撑满100%,在新版本Hbuilder中出现的问题。的实战教程也可以访问 https://www.itying.com/category-93-b0.html


这是一个已知的HBuilderX 3.1.22版本在Android平台上的兼容性问题。问题根源在于新版Webview内核对LivePusher组件渲染机制的调整。

解决方案:

  1. 临时方案:在CSS中为LivePusher容器添加明确的尺寸样式:
.pusher {
  width: 100vw;
  height: 100vh;
  position: absolute;
  top: 0;
  left: 0;
}
  1. 推荐方案:在创建LivePusher后,通过JavaScript动态设置其样式:
setTimeout(() => {
  const pusherElement = document.getElementById('pusher');
  if(pusherElement) {
    pusherElement.style.width = window.innerWidth + 'px';
    pusherElement.style.height = window.innerHeight + 'px';
  }
}, 100);
回到顶部