HarmonyOS鸿蒙next如何获取屏幕尺寸

HarmonyOS鸿蒙next如何获取屏幕尺寸呢?

HarmonyOS鸿蒙next获取屏幕尺寸可以使用 @ohos.display这个模块

获取屏幕尺寸完整代码如下:

import display from '[@ohos](/user/ohos).display';
  getScreenSize() {
    //像素尺寸 px
    let displayClass = display.getDefaultDisplaySync()
    this.screenWidth = displayClass.width
    this.screenHeight = displayClass.height
  }

更多关于HarmonyOS鸿蒙next如何获取屏幕尺寸的实战教程也可以访问 https://www.itying.com/category-93-b0.html

回到顶部