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

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

上级 cf2f542e
......@@ -37,6 +37,7 @@
methods: {
getAppBaseInfo: function () {
const res = uni.getAppBaseInfo();
this.items = [] as Item[];
for(const key in res){
const value = res[key];
if(value != null){
......
......@@ -56,6 +56,7 @@ export default {
methods: {
getDeviceInfo: function () {
const res = uni.getDeviceInfo();
this.items = [] as Item[];
for(const key in res){
const value = res[key];
if(value != null){
......
......@@ -28,8 +28,11 @@
</view>
<view class="uni-padding-wrap">
<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>
</view>
</view>
......@@ -57,6 +60,7 @@ export default {
getSystemInfo: function () {
uni.getSystemInfo({
success: (res) => {
this.items = [] as Item[];
for(const key in res){
const value = res[key];
if(value != null){
......@@ -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{
return uni.getSystemInfoSync();
......
......@@ -37,6 +37,7 @@
methods: {
getWindowInfo: function () {
const res = uni.getWindowInfo();
this.items = [] as Item[];
for(const key in res){
const value = res[key];
if(value != null){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册