交易所前端蓝色ui, 4.5 jiem
jhzh
2024-04-08 67357c691325dc3cf743267f1ef0e1f5c93d7528
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
<template>
  <div class="relative">
    <input ref="input" class="w-full h-full py-30 px-22 box-border" type="text"
      :style="{ 'background': bgColor, 'color': color }" :value="value" @input="changeVal" :placeholder="placeholder"
      maxlength="6">
    <div class="absolute flex items-center text-blue font-28 btn">
      <img @click="clear" v-show="value.length > 0" class="w-34 h-34 mr-25" src="~@/assets/image/c2c/delete.png" alt="">
      <span @click="rightClick">{{ btnText }}</span>
    </div>
  </div>
</template>
 
<script>
export default {
  name: "BusInput",
  // props: ['value', 'bgColor']
  props: {
    value: {
      required: true
    },
    bgColor: {
      default: '#F5F5F5'
    },
    color: {
      default: '#000'
    },
    placeholder: {
      required: true
    },
    btnText: {
 
    },
    maxlength: {
      default: 20
    }
  },
  methods: {
    changeVal(e) {
      const reg = /^\d*$/;
      if (reg.test(e.target.value)) {
        this.$emit("input", e.target.value)
      } else {
        const value = e.target.value
        e.target.value = value.slice(0, value.length - 1)
      }
    },
    clear() {
      this.value = ''
      this.$refs.input.focus();
    },
    rightClick() {
      this.$emit('right-click')
    }
  }
}
</script>
 
<style lang="scss" scoped>
input {
  border: none;
  outline: none;
  border-radius: 10px;
  color: #000;
 
  &::placeholder {
    color: #B8BCC5;
  }
}
 
 
.btn {
  top: 50%;
  right: 36px;
  transform: translateY(-50%);
}
</style>