<a-date-picker v-model="selectTime" show-time format="YYYY/MM/DD HH:mm:ss" valueFormat="YYYY-MM-DD HH:mm:ss" :disabled-date="disabledDate" :disabled-time="disabledTime" placeholder="请选择时间" />
import moment from 'moment';
// 设置禁用日期(年月日) disabledDate(current) { // 禁用今天之前的日期 return moment(current).add(1, 'day') < new Date() },
// 设置禁用的时分秒 disabledTime(current) { return { disabledHours: () => this.getDisabledHours(current || moment(new Date())), disabledMinutes: () => this.getDisabledMinutes(current || moment(new Date())), disabledSeconds: () => this.getDisabledSeconds(current || moment(new Date())), }; }, getDisabledHours(date) { const hours = []; for (let i = 0; i < 24; i++) { if (moment().isAfter(date.clone().hour(i))) { hours.push(i); } } return hours; }, getDisabledMinutes(date) { const minutes = []; for (let i = 0; i < 60; i++) { if (moment().isAfter(date.clone().minute(i))) { minutes.push(i); } } return minutes; }, getDisabledSeconds(date) { const seconds = []; for (let i = 0; i < 60; i++) { if (moment().isAfter(date.clone().second(i))) { seconds.push(i); } } return seconds; }
标签:picker,return,current,Date,moment,date,new,时分秒 From: https://www.cnblogs.com/djjlovedjj/p/17926359.html