Skip to content

device

device: Object

提供有关系统和窗口信息的实用方法

Type declaration

NameType
getSystemInfoSync() => any
getMenuButtonBoundingClientRect() => any
getNavbarHeight() => number
getNavbarRightOffset() => number
getPixelRatio() => number
getSafeAreaInsets() => any
getScreenHeight() => number
getScreenWidth() => number
getStatusBarHeight() => number
getTitleBarHeight() => number
getWindowHeight() => number
getWindowWidth() => number
hasBottomSafeArea() => boolean
hasTopSafeArea() => boolean
inBrowser() => boolean
isAndroid() => boolean
isDevtools() => boolean
isIOS() => boolean
isMac() => boolean
isPc() => boolean
isWindows() => boolean
px2rpx(width: number) => number
rpx2px(width: number) => number

getSystemInfoSync: () => any

同步获取系统信息


getMenuButtonBoundingClientRect: () => any

获取菜单按钮的布局信息


getNavbarHeight: () => number

获取导航栏高度


getNavbarRightOffset: () => number

获取导航栏右侧偏移量


getPixelRatio: () => number

获取像素精度


getSafeAreaInsets: () => any

获取设备安全区域信息


getScreenHeight: () => number

获取屏幕高度


getScreenWidth: () => number

获取屏幕宽度


getStatusBarHeight: () => number

获取状态栏宽度


getTitleBarHeight: () => number

获取标题栏高度


getWindowHeight: () => number

获取视窗高度


getWindowWidth: () => number

获取视窗宽度


hasBottomSafeArea: () => boolean

检查是否存在底部安全区域 取代以前的 isIpx() 方法


hasTopSafeArea: () => boolean

检查是否存在顶部安全区域


inBrowser: () => boolean

判断当前是否为浏览器环境


isAndroid: () => boolean

判断当前机器是否为 Android


isDevtools: () => boolean

判断当前环境是否为开发者工具


isIOS: () => boolean

判断当前机器是否为 iOS


isMac: () => boolean

判断当前机器是否为 Mac


isPc: () => boolean

判断当前机器是否为 PC


isWindows: () => boolean

判断当前机器是否为 Windows


px2rpx: (width: number) => number

px 转 rpx


rpx2px: (width: number) => number

rpx 转 px


源码

device.js