he wei
2024-07-31 af9733ab928ccc696cc00675fa2b2af85797b47c
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
80
81
82
83
84
85
86
<template>
  <g
    ref="g"
    :transform="
      'translate(' +
      offset.join(',') +
      ')' +
      (isVertical ? ' rotate(90 0 0)' : '')
    "
  >
    <rect
      :y="y"
      :rx="rx"
      :width="width"
      :height="height"
      stroke="none"
      :fill="color"
    ></rect>
    <text
      :x="tx"
      :font-size="fontSize"
      :fill="fontColor"
      dominant-baseline="middle"
      text-anchor="middle"
      >{{text}}</text
    >
  </g>
</template>
 
<script>
export default {
  name: "",
  props: {
    width: {
      type: Number,
      default: 80,
    },
    height: {
      type: Number,
      default: 30,
    },
    rx: {
      type: Number,
      default: 6,
    },
    fontSize: {
      type: Number,
      default: 60,
    },
    offset: {
      type: Array,
      default() {
        return [0, 0];
      },
    },
    isVertical: {
      type: Boolean,
      default: false,
    },
    text: {
      type: String,
      default: "~",
    },
    color: {
      type: String,
      default: "#0ff",
    },
    fontColor: {
      type: String,
      default: "#000",
    },
  },
  computed: {
    tx() {
      let { width, height, fontSize } = this;
      return width / 2;
    },
    y() {
      let { width, height, fontSize } = this;
      return height / -2;
    },
  },
};
</script>
 
<style scoped lang="less"></style>