Legend.vue 1.13 KB
<template>
  <div class="legend">
    <div class="legend-item flex" v-for="(item, index) in dataList" :key="index">
      <span :style="{ background: colors[index] }"></span>
      {{ item.name }}
    </div>
  </div>
</template>
<script>
export default {
  name: 'Legend',
  data() {
    return {
      dataList: this.list
    }
  },
  props: {
    list: {
      type: Array,
      default: () => []
    },
    colors: {
      type: Array,
      default: () => [' #FF6E76', '#7CFFB2', ' #FDF006', '#4FA0FF', '#EB6001']
    }
  },
  watch: {
    list(val) {
      this.dataList = val
    }
  },
  mounted() {},
  methods: {}
}
</script>

<style lang="scss" scoped>
.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  width: 7.7vw;
  height: 8.54vh;
  margin-left: 0.42vw;
  .legend-item {
    width: 3.68vw;
    height: 2.44vh;
    background: #0d133b;
    align-items: center;
    font-size: 7px;
    color: #fff;
    box-sizing: border-box;
    margin: 2px 2px 2px 0;
    white-space: nowrap;
    span {
      width: 5px;
      height: 5px;
      background: #bf98ff;
      border-radius: 50%;
      margin: 4px;
    }
  }
}
</style>