zjf
2023-03-08 92b359a6458fb985b78431e0a2f54b548e01b1ca
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
78
79
<template>
  <div
    v-show="visible"
    class="photo-wrap">
    <flexbox
      :style="{'font-size' : fontSize+'px'}"
      class="photo-content"
      justify="center"
      align="center">
      <div v-if="text">{{ text }}</div>
    </flexbox>
  </div>
</template>
 
<script>
export default {
  data () {
    return {
      text: null,
      visible: false,
      fontSize: 12
    }
  },
  computed: {},
  watch: {
    visible: function (params) {
      this.$nextTick(() => {
        if (this.$el.getBoundingClientRect().height > 0) {
          let fontSize = this.$el.getBoundingClientRect().height * 0.38
          if (fontSize > 40) {
            fontSize = 40
          }
          this.fontSize = fontSize
        } else {
          this.fontSize = 12
        }
      })
    }
  },
  mounted () {},
  methods: {
    setText (text) {
      if (text) {
        this.text = text
      }
    },
    setIcon (icon) {
      this.icon = icon
    }
  }
}
</script>
 
<style lang="scss" scoped>
.photo-wrap {
  position: absolute;
  z-index: 1;
  // background-color: white;
  margin: 0;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  .photo-content {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #2486e4;
    color: white;
    div {
      width: 100%;
      text-align: center;
      transform: scale(0.9, 0.9);
      max-height: 50px;
      overflow: hidden;
    }
  }
}
</style>