潘毅康
潘毅康
  • 发布:2020-10-09 15:11
  • 更新:2020-10-16 09:31
  • 阅读:1928

【报Bug】uni.getSystemInfoSync获取手机的宽度和高度无效

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

HBuilderX类型: 正式

HBuilderX版本号: 2.8.13

手机系统: Android

手机系统版本号: Android 9.0

手机厂商: 魅族

手机机型: 16thplus

页面类型: nvue

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

<div>
<map style="{{width:style.width,height:style.height}}"></map>
</div>
uni.getSystemInfoSync//获取赋值给style

操作步骤:

<div>
<map style="{{width:style.width,height:style.height}}"></map>
</div>
uni.getSystemInfoSync//获取赋值给style

预期结果:

获取手机的宽高赋值给map,实现地图全屏

实际结果:

地图并没有全屏,出现滚动轮,无法移动地图,Hbulider2.7打包正常使用,新版打包才有这个问题

bug描述:

uni.getSystemInfoSync获取手机的宽度和高度然后:style绑定到map组件让地图全屏无效,该bug在hublider2.7时候不存在,今天更新到最新版Hubilder就有这个问题,是云端打包以后才会有,本地基座调试的时候一切正常
已确定bug是仅在nvue页面会有这个问题,vue页面不会有这个问题。请看我的测试demo

2020-10-09 15:11 负责人:无 分享
已邀请:
chenli

chenli

自定义基座调试正常吗?

  • 潘毅康 (作者)

    HBuilderX2.7.14本地基座和自定义基座和打包都正常,最新版HBuilderX本地基座正常,自定义基座和打包都有异常,重新下载最新版还是存在这个问题

    2020-10-09 15:44

  • chenli

    回复 潘毅康: <map> 组件的宽/高推荐写直接量,比如:750rpx,不要设置百分比值。

    2020-10-09 16:16

  • 潘毅康 (作者)

    回复 chenli: 并没有设置百分值,我用uni.getSystemInfoSync获取的是设备固定值然后动态绑定到map组件上

    2020-10-09 17:17

  • chenli

    回复 潘毅康: 这里获取的值是没有单位的,有添加单位吗?

    2020-10-09 17:22

  • 潘毅康 (作者)

    回复 chenli: let sysInfo = uni.getSystemInfoSync();

    this.style.height = sysInfo.windowHeight ? sysInfo.windowHeight + 'px' : '880px';

    this.style.width = sysInfo.windowWidth ? sysInfo.windowWidth + 'px' : '880px';

    2020-10-09 17:46

  • 潘毅康 (作者)

    回复 chenli: 如果是我的问题的话,之前就不会一直都能用。这是我的代码片段

    2020-10-09 17:46

  • DCloud_UNI_GSQ

    回复 潘毅康: 打印一下 sysInfo

    2020-10-09 18:30

  • 潘毅康 (作者)

    回复 DCloud_UNI_GSQ: {

    "errMsg": "getSystemInfoSync:ok",

    "brand": "Meizu",

    "model": "16th Plus",

    "pixelRatio": 3,

    "screenWidth": 360,

    "screenHeight": 720,

    "windowWidth": 360,

    "windowHeight": 720,

    "statusBarHeight": 28,

    "language": "zh-CN",

    "system": "8.1.0",

    "version": "1.9.9.80432",

    "fontSizeSetting": "",

    "platform": "android",

    "SDKVersion": "",

    "windowTop": 0,

    "windowBottom": 0,

    "safeArea": {

    "left": 0,

    "right": 360,

    "top": 28,

    "bottom": 720,

    "width": 360,

    "height": 692

    },

    "safeAreaInsets": {

    "top": 28,

    "right": 0,

    "bottom": 0,

    "left": 0

    }

    }

    2020-10-09 22:13

  • 潘毅康 (作者)

    你看一下我下面打印出来的同一个手机两个HbuilderX版本获取的设备数据,

    2020-10-11 10:37

潘毅康

潘毅康 (作者) - pyk

测试新版HBuilderx uni.getSystemInfoSync在nvue地图页面的bug 尝试把nvue页面换成vue发现一切正常,经测试在HbuilderX2.7.14是最后可行的版本,在此之后的版本都有这个bug

  • DCloud_UNI_GSQ

    试试最新的 alpha 版

    2020-10-10 20:06

  • 潘毅康 (作者)

    回复 DCloud_UNI_GSQ: 我这边测试最新的 alpha 版也是不行,但是我发现同一款手机新版本的HbuilderX获取的设备高度720,旧版本的HbuilderX获取的高度是690px

    2020-10-11 10:12

  • 潘毅康 (作者)

    回复 DCloud_UNI_GSQ: 你看一下我下面打印出来的同一个手机两个HbuilderX版本获取的设备数据,

    2020-10-11 10:37

潘毅康

潘毅康 (作者) - pyk

复制代码新旧版本的Hbuildex获取同一手机的高不一样,也就导致了新版本获取的高赋值给map组件无法全屏  
旧版本:{  
    "errMsg": "getSystemInfoSync:ok",  
    "brand": "Meizu",  
    "model": "16th Plus",  
    "pixelRatio": 3,  
    "screenWidth": 360,  
    "screenHeight": 690,  
    "windowWidth": 360,  
    "windowHeight": 690,  
    "statusBarHeight": 28,  
    "language": "zh-CN",  
    "system": "8.1.0",  
    "version": "1.9.9.80255",  
    "fontSizeSetting": "",  
    "platform": "android",  
    "SDKVersion": "",  
    "windowTop": 0,  
    "windowBottom": 0,  
    "safeArea": {  
        "left": 0,  
        "right": 360,  
        "top": 28,  
        "bottom": 690,  
        "width": 360,  
        "height": 662  
    },  
    "safeAreaInsets": {  
        "top": 28,  
        "right": 0,  
        "bottom": 0,  
        "left": 0  
    }  
}  

新版本:{  
    "errMsg": "getSystemInfoSync:ok",  
    "brand": "Meizu",  
    "model": "16th Plus",  
    "pixelRatio": 3,  
    "screenWidth": 360,  
    "screenHeight": 720,  
    "windowWidth": 360,  
    "windowHeight": 720,  
    "statusBarHeight": 28,  
    "language": "zh-CN",  
    "system": "8.1.0",  
    "version": "1.9.9.80432",  
    "fontSizeSetting": "",  
    "platform": "android",  
    "SDKVersion": "",  
    "windowTop": 0,  
    "windowBottom": 0,  
    "safeArea": {  
        "left": 0,  
        "right": 360,  
        "top": 28,  
        "bottom": 720,  
        "width": 360,  
        "height": 692  
    },  
    "safeAreaInsets": {  
        "top": 28,  
        "right": 0,  
        "bottom": 0,  
        "left": 0  
    }  
}
潘毅康

潘毅康 (作者) - pyk

有人回答吗?

潘毅康

潘毅康 (作者) - pyk

有人回复吗?

该问题目前已经被锁定, 无法添加新回复

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

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

## 大标题 
### 小标题

斜体 / 粗体 :

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

代码片段 :

``` 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

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

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