price.vue
823 Bytes
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
<template>
<div>
<Input :value="start" class="price-input" @input="startChange"></Input>
~
<Input :value="end" class="price-input" @input="endChange"></Input>
</div>
</template>
<script>
export default {
name: 'Price',
props: {
value: {
type: Array,
default() {
return [];
},
},
},
data() {
const self = this;
return {
start: self.value[0] || null,
end: self.value[1] || null,
};
},
watch: {
value(newVal) {
this.start = newVal[0];
this.end = newVal[1];
},
},
methods: {
startChange(data) {
this.$emit('input', [data, this.end]);
},
endChange(data) {
this.$emit('input', [this.start, data]);
},
},
};
</script>
<style lang="scss" scoped>
.price-input {
width: 45%;
}
</style>