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

fix: 1. 添加api示例的重置逻辑 2. getsysteminfo示例添加同步获取方式

上级 cf2f542e
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
methods: { methods: {
getAppBaseInfo: function () { getAppBaseInfo: function () {
const res = uni.getAppBaseInfo(); const res = uni.getAppBaseInfo();
this.items = [] as Item[];
for(const key in res){ for(const key in res){
const value = res[key]; const value = res[key];
if(value != null){ if(value != null){
......
...@@ -56,6 +56,7 @@ export default { ...@@ -56,6 +56,7 @@ export default {
methods: { methods: {
getDeviceInfo: function () { getDeviceInfo: function () {
const res = uni.getDeviceInfo(); const res = uni.getDeviceInfo();
this.items = [] as Item[];
for(const key in res){ for(const key in res){
const value = res[key]; const value = res[key];
if(value != null){ if(value != null){
......
...@@ -28,8 +28,11 @@ ...@@ -28,8 +28,11 @@
</view> </view>
<view class="uni-padding-wrap"> <view class="uni-padding-wrap">
<view class="uni-btn-v"> <view class="uni-btn-v">
<button type="primary" @tap="getSystemInfo"> <button type="primary" @tap="getSystemInfoSync">
获取设备系统信息 同步获取设备系统信息
</button>
<button type="primary" @tap="getSystemInfo" style="margin-top: 20px;">
异步获取设备系统信息
</button> </button>
</view> </view>
</view> </view>
...@@ -57,6 +60,7 @@ export default { ...@@ -57,6 +60,7 @@ export default {
getSystemInfo: function () { getSystemInfo: function () {
uni.getSystemInfo({ uni.getSystemInfo({
success: (res) => { success: (res) => {
this.items = [] as Item[];
for(const key in res){ for(const key in res){
const value = res[key]; const value = res[key];
if(value != null){ if(value != null){
...@@ -70,6 +74,20 @@ export default { ...@@ -70,6 +74,20 @@ export default {
}, },
}) })
}, },
getSystemInfoSync: function () {
this.items = [] as Item[];
const res = uni.getSystemInfoSync()
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_getSystemInfo():GetSystemInfoResult{ jest_getSystemInfo():GetSystemInfoResult{
return uni.getSystemInfoSync(); return uni.getSystemInfoSync();
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
methods: { methods: {
getWindowInfo: function () { getWindowInfo: function () {
const res = uni.getWindowInfo(); const res = uni.getWindowInfo();
this.items = [] as Item[];
for(const key in res){ for(const key in res){
const value = res[key]; const value = res[key];
if(value != null){ if(value != null){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册