riku
2024-05-10 f5624d6a7ad32ee475e00edbad26bc98ea4629e1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<template>
  <el-row class="wrap">
    <el-form :inline="true">
      <el-form-item label="车速:" class="tag-2">
        {{ speed }}
      </el-form-item>
    </el-form>
    <GaugeChart name="车速" :speed="speed"></GaugeChart>
  </el-row>
</template>
<script>
import { FactorDatas } from '@/model/FactorDatas';
 
export default {
  props: {
    loading: Boolean,
    factorDatas: FactorDatas
  },
  data() {
    return {
      speed: '--km/h'
    };
  },
  watch: {
    factorDatas: {
      handler(nV) {
        this.speed = this.lastOne(nV, '14') + 'km/h';
      },
      deep: true
    }
  },
  methods: {
    lastOne(factorDatas, key) {
      const f = factorDatas.factor[key];
      if (f) {
        const lastIndex = f.datas.length - 1;
        return factorDatas.factor[key].datas[lastIndex].factorData;
      } else {
        return '--';
      }
    }
  }
};
</script>