From 3522b9d6b1b17e6ab6c87ab039587bce84faa52c Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Tue, 18 Jun 2024 13:17:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(getDeviceInfo):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=B0=83=E6=95=B4=E5=90=8E=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E7=B1=BB=E5=9E=8B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../API/get-device-info/get-device-info.uvue | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/pages/API/get-device-info/get-device-info.uvue b/pages/API/get-device-info/get-device-info.uvue index 72f0b557..6c655702 100644 --- a/pages/API/get-device-info/get-device-info.uvue +++ b/pages/API/get-device-info/get-device-info.uvue @@ -14,7 +14,9 @@ }} - {{ item.value == '' ? '未获取' : item.value }} + {{ + item.value == "" ? "未获取" : item.value + }} @@ -50,25 +52,25 @@ getDeviceInfo: function () { const res = uni.getDeviceInfo(); // 获取像素比, 供截图对比使用 - setDevicePixelRatio(res.devicePixelRatio !== null ? parseFloat(res.devicePixelRatio!) : 1) - 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); - } + setDevicePixelRatio(res.devicePixelRatio !== null ? res.devicePixelRatio! : 1) + 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); + } }); } } -- GitLab