提交 47d2beb8 编写于 作者: taohebin@dcloud.io's avatar taohebin@dcloud.io

fix: 修改getsysteminfo等api的实现方式、处理报错警告

上级 a4741c42
...@@ -37,17 +37,16 @@ ...@@ -37,17 +37,16 @@
methods: { methods: {
getAppBaseInfo: function () { getAppBaseInfo: function () {
const res = uni.getAppBaseInfo(); const res = uni.getAppBaseInfo();
//类型对象暂时不支持forin或Object.keys(), 临时通过字符串进行转化。 for(const key in res){
const json = JSON.stringify(res); const value = res[key];
const result = JSON.parse<Map<string, any>>(json); if(value != null){
this.items = [] as Item[]; const item = {
result?.forEach((value, key) => { label: key,
const item = { value: "" + ((typeof value == "object")? JSON.stringify(value) : value)
label: key, } as Item;
value: "" + value this.items.push(item);
} as Item; }
this.items.push(item); }
})
} }
} }
} }
......
...@@ -56,17 +56,16 @@ export default { ...@@ -56,17 +56,16 @@ export default {
methods: { methods: {
getDeviceInfo: function () { getDeviceInfo: function () {
const res = uni.getDeviceInfo(); const res = uni.getDeviceInfo();
//类型对象暂时不支持forin或Object.keys(), 临时通过字符串进行转化。 for(const key in res){
const json = JSON.stringify(res); const value = res[key];
const result = JSON.parse<Map<string, any>>(json); if(value != null){
this.items = [] as Item[]; const item = {
result?.forEach((value, key) => { label: key,
const item = { value: "" + ((typeof value == "object")? JSON.stringify(value) : value)
label: key, } as Item;
value: "" + value this.items.push(item);
} as Item; }
this.items.push(item); }
})
} }
} }
} }
......
...@@ -56,18 +56,17 @@ export default { ...@@ -56,18 +56,17 @@ export default {
methods: { methods: {
getSystemInfo: function () { getSystemInfo: function () {
uni.getSystemInfo({ uni.getSystemInfo({
success: (res) => { success: (res) => {
//类型对象暂时不支持forin或Object.keys(), 临时通过字符串进行转化。 for(const key in res){
const json = JSON.stringify(res); const value = res[key];
const result = JSON.parse<Map<string, any>>(json); if(value != null){
this.items = [] as Item[]; const item = {
result?.forEach((value, key) => { label: key,
const item = { value: "" + ((typeof value == "object")? JSON.stringify(value) : value)
label: key, } as Item;
value: "" + value this.items.push(item);
} as Item; }
this.items.push(item); }
})
}, },
}) })
} }
......
...@@ -37,17 +37,16 @@ ...@@ -37,17 +37,16 @@
methods: { methods: {
getWindowInfo: function () { getWindowInfo: function () {
const res = uni.getWindowInfo(); const res = uni.getWindowInfo();
//类型对象暂时不支持forin或Object.keys(), 临时通过字符串进行转化。 for(const key in res){
const json = JSON.stringify(res); const value = res[key];
const result = JSON.parse<Map<string, any>>(json); if(value != null){
this.items = [] as Item[]; const item = {
result?.forEach((value, key) => { label: key,
const item = { value: "" + ((typeof value == "object")? JSON.stringify(value) : value)
label: key, } as Item;
value: "" + value this.items.push(item);
} as Item; }
this.items.push(item); }
})
} }
} }
} }
......
...@@ -137,7 +137,7 @@ export default { ...@@ -137,7 +137,7 @@ export default {
uni.sendSocketMessage({ uni.sendSocketMessage({
data: data:
'from ' + 'from ' +
platform + this.platform +
' : ' + ' : ' +
parseInt((Math.random() * 10000).toString()).toString(), parseInt((Math.random() * 10000).toString()).toString(),
success(res: any) { success(res: any) {
......
...@@ -17,8 +17,10 @@ ...@@ -17,8 +17,10 @@
content: "", content: "",
} }
}, },
onLoad(event) { onLoad(event) {
this.content = event["content"] ?? ""; if(event != null){
this.content = event["content"] ?? "";
}
}, },
methods: { methods: {
} }
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
for(let i = 0; i < 100; i++){ for(let i = 0; i < 100; i++){
temp = temp.concat(items); temp = temp.concat(items);
} }
listData = temp; this.listData = temp;
} }
setTimeout(()=>{ setTimeout(()=>{
this.refresherTriggered = false this.refresherTriggered = false
......
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
</view> </view>
</view> </view>
<!-- //todo 还有自定义下拉刷新样式的例子 -->
<view class="uni-common-pb"></view> <view class="uni-common-pb"></view>
</scroll-view> </scroll-view>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册