uni-app提供了异步(uni.getSystemInfo
)和同步(uni.getSystemInfoSync
)的2个API获取系统信息。
具体使用:
//data声明变量 windowWidth windowHeight //created 获取信息 uni.getSystemInfo({ success: (res) => { this.windowWidth = res.windowWidth; this.windowHeight = res.windowHeight; console.log("宽度:", this.windowWidth); console.log("高度:", this.windowHeight); }, });
返回的数据: