

English
同步获取窗口信息
Type |
---|
GetWindowInfoResult |
name | type | optinal | default | description |
---|---|---|---|---|
pixelRatio | number | YES | - | 设备像素比 |
screenWidth | number | YES | - | 屏幕宽度 |
screenHeight | number | YES | - | 屏幕高度 |
windowWidth | number | YES | - | 可使用窗口宽度 |
windowHeight | number | YES | - | 可使用窗口高度 |
statusBarHeight | number | YES | - | 状态栏的高度 |
windowTop | number | YES | - | 可使用窗口的顶部位置 |
windowBottom | number | YES | - | 可使用窗口的底部位置 |
safeArea | SafeArea | YES | - | 在竖屏正方向下的安全区域 |
safeAreaInsets | SafeAreaInsets | YES | - | 在竖屏正方向下的安全区域插入位置 |
screenTop | number | YES | - | 窗口上边缘的 y 值 |
name | type | optinal | default | description |
---|---|---|---|---|
left | number | YES | - | 安全区域左上角横坐标 |
right | number | YES | - | 安全区域右下角横坐标 |
top | number | YES | - | 安全区域左上角纵坐标 |
bottom | number | YES | - | 安全区域右下角纵坐标 |
width | number | YES | - | 安全区域的宽度,单位逻辑像素 |
height | number | YES | - | 安全区域的高度,单位逻辑像素 |
name | type | optinal | default | description |
---|---|---|---|---|
left | number | YES | - | 安全区域左侧插入位置 |
right | number | YES | - | 安全区域右侧插入位置 |
top | number | YES | - | 安全区顶部插入位置 |
bottom | number | YES | - | 安全区域底部插入位置 |
Android version | Android uni-app | Android uni-app-x | iOS version | iOS uni-app | iOS uni-app-x |
---|---|---|---|---|---|
4.4 | √ | 3.9+ | 9.0 | √ | x |
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-common-mt">
<view class="uni-list">
<view class="uni-list-cell" v-for="(item,_) in items" style="align-items: center;">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">{{item.label}}</view>
</view>
<view class="uni-list-cell-db">
<textarea :auto-height="true" :disabled="true" placeholder="未获取" :value="item.value" />
</view>
</view>
</view>
<view class="uni-padding-wrap">
<view class="uni-btn-v">
<button type="primary" @tap="getWindowInfo">获取窗口信息</button>
</view>
</view>
</view>
</view>
</template>
<script>
type Item = {
label : string,
value : string,
}
export default {
data() {
return {
title: 'getWindowInfo',
items: [] as Item[],
}
},
onUnload: function () {
},
methods: {
getWindowInfo: function () {
const res = uni.getWindowInfo();
this.items = [] as Item[];
for(const key in res){
const value = res[key];
if(value != null){
const item = {
label: key,
value: "" + ((typeof value == "object")? JSON.stringify(value) : value)
} as Item;
this.items.push(item);
}
}
},
//自动化测试例专用
jest_getWindowInfo():GetWindowInfoResult{
return uni.getWindowInfo();
},
}
}
</script>
<style>
.uni-pd {
padding-left: 30rpx;
}
</style>
name | type | optinal | default | description |
---|---|---|---|---|
errMsg | string | YES | - | 错误信息 |