Ant Design of Vue RangePicker 時間選擇器限 限制選擇當前之后日期且不能跨月選擇



<a-range-picker
    :ranges="{
        今天: [moment(), moment()],
        本月: [moment(), moment().endOf('month')]
    }"
    :placeholder="['開始日期', '結束日期']"
    :allowClear="true"
    :disabled-date="disabledDate"
    @change="onChange"
    @calendarChange="calendarChange"
/>

import moment from 'moment'
export default {
    name: 'invoiceFix',
    data() {
        return {
            choiceDate: "",
        }
    },
    methods: {
        moment,
        onChange([startTime]) {
            this.choiceDate = startTime
        },
        calendarChange([startTime]) {
            this.choiceDate = startTime
        },
        disabledDate(current) {
            if (this.choiceDate) {
                return current.month() + 1 != moment(this.choiceDate).format("MM") || current > moment().endOf('day');
            } else {
                return current && current > moment().endOf('day')
            }
        }
    }
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM