npm.io
2.3.12 • Published 7 years ago

nuke-dimensions

Licence
Apache-2.0
Version
2.3.12
Deps
1
Size
26 kB
Vulns
0
Weekly
0

Dimensions

  • category: API
  • chinese: 屏幕参数
  • type: API 能力

何时使用

由于 weex 容器不支持 height : 100% ,当你需要获取屏幕宽高的 rem 数值时并设置样式时,需要 Dimensions 组件。

API

获取尺寸: Dimensions.get('window/screen')

获取 window 或 screen 的尺寸,默认竖屏

// 获取屏幕宽高的 rem 数值
let { height, width } = Dimensions.get('window');
获取横屏属性: Dimensions.getWindowInfo(isLandscape)

isLandscape 为 true 时,返回横屏宽高。

需当前页面在容器横屏下打开,否则将出现不可预料的数值

// 获取横屏模式下宽高
let { height, width } = Dimensions.getWindowInfo(true);

其他

  • bug、建议联系 @翊晨
  • 钉钉交流群

Keywords