diff --git a/pages/API/get-window-info/get-window-info.uvue b/pages/API/get-window-info/get-window-info.uvue index 728f33a13417bf174a1af5fc6dd4e63782f7e9ff..0a739a0c8376935efe97079372181f047c56aea9 100644 --- a/pages/API/get-window-info/get-window-info.uvue +++ b/pages/API/get-window-info/get-window-info.uvue @@ -42,17 +42,25 @@ const res = uni.getWindowInfo(); // 获取状态栏+导航栏高度, 供截图对比使用 setStatusBarHeight(res.statusBarHeight); - 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); - } - } + this.items = [] as Item[]; + + const res_str = JSON.stringify(res); + const res_obj = JSON.parseObject(res_str); + const res_map = res_obj!.toMap(); + let keys = [] as string[] + res_map.forEach((_, key) => { + keys.push(key); + }); + keys.sort().forEach( key => { + 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 {