input-price.vue
1.13 KB
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
<template>
<div class="input-wrapper">
<div class="price-symbol">¥</div>
<input ref="input" :value="value" class="tip" type="text" placeholder="定价需以9结尾,例如¥1299" @blur="onBlur"
@change="onChange"></input>
</div>
</template>
<script>
export default {
name: 'InputPrice',
props: {
value: {
type: [Number, String],
default: ''
}
},
data() {
return {
val: this.value
};
},
methods: {
onBlur() {
this.$emit('on-blur');
},
onChange() {
this.$emit('input', this.$refs.input.value);
}
},
watch: {
value(newVal) {
this.val = newVal;
}
}
};
</script>
<style lang="scss" scoped>
.input-wrapper {
display: flex;
position: relative;
overflow: hidden;
height: 120px;
background: #f5f5f5;
}
.price-symbol {
width: 40px;
margin-left: 20px;
margin-right: 10px;
font-size: 40px;
font-weight: bolder;
line-height: 120px;
}
.tip {
flex: 1;
font-size: 56px;
font-weight: 500;
line-height: 120px;
background: #f5f5f5;
}
::placeholder {
color: #ccc;
font-size: 28px;
opacity: 1; /* Firefox */
}
</style>