1
suerprisePlus
2024-06-06 7acf7ad6948e3e952173a2551ea4a92a8ff56c35
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<template>
  <div class="headerBox">
    <div
      class="headBox"
      :class="menuCheckFlg === item.id ? 'headBoxActive' : ''"
      v-for="(item, index) in menuOption"
      :key="index"
      @click="setMenuChange(item)"
    >
      <img
        class="itemImg"
        :src="require(`../../assets/img/map/${item.image}`)"
      />
    </div>
  </div>
</template>
 
<script>
export default {
  props: {
    dataTypes: {
      type: Array,
      // 当为数组类型设置默认值时必须使用数组返回
      default: function (value) {
        return [];
      }
    }
  },
  data() {
    return {
      menuOption: this.dataTypes,
      menuCheckFlg: null
    };
  },
  methods: {
    setMenuChange(res) {
      this.menuCheckFlg = res.id;
      if (res.id == "c2") {
        this.$store.state.setScreenFlag = !this.$store.state.setScreenFlag;
      }
    }
  },
  watch: {
    dataTypes(newValue, oldValue) {
      if (newValue) {
        this.menuOption = newValue;
        this.menuCheckFlg = this.menuOption[0].id;
      }
    }
  }
};
</script>
 
<style scoped>
.headerBox {
  display: flex;
  align-items: center;
}
.headBox {
  border: 1px solid rgba(0, 0, 0, 0);
  box-sizing: border-box;
  margin-right: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
}
 
.headBoxActive {
  border: 1px solid #797979;
  background-color: #797979;
}
.headBox img {
  width: 16px;
  height: 13px;
  margin: 5px;
}
</style>