提交 3522b9d6 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬 提交者: 雪洛

fix(getDeviceInfo): 修复类型调整后导致的类型错误

上级 e63a7a51
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
}}</view> }}</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<text style="width: 100%;">{{ item.value == '' ? '未获取' : item.value }}</text> <text style="width: 100%">{{
item.value == "" ? "未获取" : item.value
}}</text>
</view> </view>
</view> </view>
</view> </view>
...@@ -50,7 +52,7 @@ ...@@ -50,7 +52,7 @@
getDeviceInfo: function () { getDeviceInfo: function () {
const res = uni.getDeviceInfo(); const res = uni.getDeviceInfo();
// 获取像素比, 供截图对比使用 // 获取像素比, 供截图对比使用
setDevicePixelRatio(res.devicePixelRatio !== null ? parseFloat(res.devicePixelRatio!) : 1) setDevicePixelRatio(res.devicePixelRatio !== null ? res.devicePixelRatio! : 1)
this.items = [] as Item[]; this.items = [] as Item[];
const res_str = JSON.stringify(res); const res_str = JSON.stringify(res);
...@@ -60,12 +62,12 @@ ...@@ -60,12 +62,12 @@
res_map.forEach((_, key) => { res_map.forEach((_, key) => {
keys.push(key); keys.push(key);
}); });
keys.sort().forEach( key => { keys.sort().forEach(key => {
const value = res[key]; const value = res[key];
if(value != null){ if (value != null) {
const item = { const item = {
label: key, label: key,
value: "" + ((typeof value == "object")? JSON.stringify(value) : value) value: "" + ((typeof value == "object") ? JSON.stringify(value) : value)
} as Item; } as Item;
this.items.push(item); this.items.push(item);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册