<!-- * @Description: 渣土车数量统计 * @Author: 王晓颖 * @Date: 2020-12-03 15:14:22 --> <template> <div style="width: 100%;height:100%;padding:0.1rem" > <div class="truck-count-container"> <image-block2 v-for="item of data" :key="item.name" :data="item"/> </div> </div> </template> <script> import ImageBlock2 from '@/components/block/imageBlock2' import {fetchTruckCount} from '@/api/cityManage' import mockData from '../../../../../../static/city.json' export default { name: 'TruckCount', components: {ImageBlock2}, data () { return { data: [ {name: '渣土车', value: '', unit: '辆'}, {name: '在线数', value: '', unit: '辆'}, {name: '在线率', value: '%', unit: ''} ] } }, created () { // this.getData() this.data = mockData.truck.count }, methods: { getData () { fetchTruckCount().then(response => { if (response.code === 200) { this.data[0].value = response.data[0].value this.data[1].value = response.data[1].value this.data[2].value = parseInt(Number(response.data[1].value) / Number(response.data[0].value) * 100) + '%' } }) } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> .truck-count-container{ // 垂直flex height: 100%; padding-left:0.03rem; padding-right:0.03rem; display: -webkit-flex; /* Safari */ display: flex; flex-direction: column; justify-content: space-between; margin:auto; } </style>