页面要求:我写的对象数组的形式
后台给我的是
html
<view @tap="goqylb" class="item">
<view class="item-top">
<view class="su">
</view>
<view class="text">
<view class="CN">
企业统计
</view>
<view class="EN">
Enterprise
</view>
</view>
</view>
<view class="echatring tongji">
<u-grid :col="2">
<u-grid-item v-for="(item,index) in qyList" :key="index">
<view class="grid-text u-flex stocrNuber">{{qyArry[index]}}
<view class="jia">家</view>
</view>
<view class="grid-text" style="color: #7A7A7A">{{item.sum}}</view>
</u-grid-item>
</u-grid>
</view>
</view>
js
qytj() {
//企业统计
this.$HTTP({
url: "接口路径...",
method: "POST",
})
.then((res) => {
if (res.data.code == 200) {
this.infodata = res.data.data
let qyArry = Object.keys(res.data.data).map((item) => {
//去除空值
if (res.data.data[item] == null) {
delete res.data.data[item];
}
return res.data.data;
});
//转为数组
this.qyArry = Object.values(qyArry[0])
console.log("企业统计", this.qyArry)
}
})
.catch((err) => {
});
},