格克
格克
  • 发布:2024-03-08 14:12
  • 更新:2024-03-11 10:12
  • 阅读:551

uniapp在横屏模式webview有样式问题

分类:uni-app

app默认是竖屏,有个页面是横屏,元素就一个webview,在ios环境顶部会多一块,怎么都去不掉

复制代码<template>  
    <web-view :src="url" ref="webview"></web-view>  
</template>  

<script>  
    export default {  
        data() {  
            return {  
                url: ''  
            };  
        },  
        onUnload() {  
            // #ifdef APP-PLUS  
            plus.screen.lockOrientation("portrait-primary");  
            // #endif  
        },  
        onLoad(e) {  
            // #ifdef APP-PLUS  
            plus.screen.lockOrientation("landscape-primary");  
            // #endif  
            this.url = "https://www.baidu.com"  
        }  
    }  
</script>
2024-03-08 14:12 负责人:无 分享
已邀请:
higough

higough

onReady() {
let currentWebview = this.$scope.$getAppWebview();
setTimeout(function() {
let wv = currentWebview.children()[0];
const windowResizeCallback = (res) => {
wv.setStyle({
top: uni.getSystemInfoSync().statusBarHeight + 44
})
}
uni.onWindowResize(windowResizeCallback);

复制代码        }, 500);  
    }
  • 格克 (作者)

    这个可以解决,但感觉还是官方的bug

    2024-03-11 11:15

套马杆的套子

套马杆的套子 - 没有解决不了的问题,只有解决不完的问题

试试是不是状态栏的事

复制代码plus.navigator.setStatusBarStyle('UIStatusBarStyleBlackTranslucent');  
  • 格克 (作者)

    不行,我感觉就是uniapp的bug

    2024-03-08 14:46

格克

格克 (作者) - cccctttwww

没有官方人来测试一下吗

Azikou

Azikou

plus.navigator.setFullscreen(true);

  • 格克 (作者)

    试了,不行

    2024-03-08 16:24

格克

格克 (作者) - cccctttwww

bug没人来看一下吗,百分百复现

要回复问题请先登录注册

  • 标题 / 粗斜体
  • 代码片段
  • 超链接 / 图片 / 视频
  • 列表 / 引用

文章内容较多时,可以用标题分段 :

## 大标题 
### 小标题

斜体 / 粗体 :

**粗体** 
*斜体*
***粗斜体***

代码片段 :

``` javascript
代码片段
```

超链接 :

[链接文字](链接地址) 例: [百度](http://www.baidu.com)

图片 :

![图片说明](图片地址) 例: ![百度logo](http://www.baidu.com/img/bdlogo.gif)

视频 :

!![视频说明](视频地址) 例: !![优酷视频](http://youku.com)

有序列表 :

1. 123
2. 123
3. 123

无序列表 :

- 123
- 123
- 123

引用 : ( 双回车后结束引用 )

> 引用内容
引用内容
引用内容