date-pick.vue
1.08 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
<template>
<Date-picker
:value="value"
:type="type"
:options="options"
@on-change="updateHandle"
clearable
placeholder="选择日期">
</Date-picker>
</template>
<script>
const DAY_MS = 86400000;
export default {
props: {
value: {
type: [Object, String],
default: null
},
type: {
type: String,
default: 'date'
},
options: {
type: Object,
default() {
return {
disabledDate(date) {
return date && date.valueOf() < Date.now() - DAY_MS;
}
};
}
}
},
methods: {
updateHandle(newValue) {
this.$emit('input', newValue);
}
},
watch: {
value(newValue) {
this.value = newValue;
}
}
};
</script>