date-pick.vue 1.08 KB
<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>