日期判断只能选择本月之前的日期
<DatePicker type="date" :options="options3" format="yyyy-MM-dd" placeholder="请选择时间" style="width: 200px"></DatePicker>
js
options3: { disabledDate (date) { function myMonth(year, month){ let d = new Date(year, month, 0); return d.getDate(); };
//a 是举例的,大家可以尝试一下 let time,a='2020-01-01'; let dateNow = new Date(a); if (dateNow.getMonth() != 0) { time = dateNow.getFullYear() + '-' + dateNow.getMonth() + '-' + myMonth(dateNow.getFullYear(), dateNow.getMonth()); } else { time = dateNow.getFullYear()-1 + '-' + 12 + '-' + myMonth(dateNow.getFullYear(), 12); } let newDate = new Date(time).getTime(); return date && date.valueOf() > newDate; } },