get-app-base-info.uvue 1.4 KB
Newer Older
1
<template>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
2 3 4 5 6 7 8 9
  <page-head :title="title"></page-head>
  <view class="uni-common-mt">
    <view class="uni-list">
      <view class="uni-list-cell" v-for="(item,_) in items" style="align-items: center;">
        <view class="uni-pd">
          <view class="uni-label" style="width:180px;">{{item.label}}</view>
        </view>
        <view class="uni-list-cell-db">
10
          <textarea style="width: 100%;" :auto-height="true" :disabled="true" placeholder="未获取" :value="item.value" />
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
11 12 13 14 15 16 17 18 19
        </view>
      </view>
    </view>
    <view class="uni-padding-wrap">
      <view class="uni-btn-v">
        <button type="primary" @tap="getAppBaseInfo">获取App基础信息</button>
      </view>
    </view>
  </view>
20 21
</template>
<script>
22 23 24 25
	type Item = {
		label : string,
		value : string,
	}
26 27 28 29
	export default {
		data() {
			return {
				title: 'getAppBaseInfo',
30
				items: [] as Item[],
31 32 33 34 35 36 37
			}
		},
		onUnload:function(){
		},
		methods: {
			getAppBaseInfo: function () {
				const res = uni.getAppBaseInfo();
38
        this.items = [] as Item[];
39 40 41 42 43 44 45 46 47 48
        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);
          }
        }
49 50 51 52 53 54 55
			}
		}
	}
</script>

<style>
	.uni-pd {
H
hdx 已提交
56
		padding-left: 15px;
57 58
	}
</style>