1.能选择的时间大于现在
<el-date-picker v-model="formData.beginTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开始时间" :disabledDate="disabledDateFn" :disabled-hours="disabledHours" :disabled-minutes="disabledMinutes" :disabled-seconds="disabledSeconds" />const disabledDateFn = (time: any) => { //比当前时间小的时间禁用(返回true则禁用) return time.getTime() < Date.now() - 24 * 3600 * 1000; }; const disabledHours = () => { const a = []; for (let i = 0; i < 24; i++) { // 限制之前 < 之后 > ,下面同理 if (new Date().getHours() <= i) continue; a.push(i); } return a; }; const disabledMinutes = () => { const a = []; for (let i = 0; i < 60; i++) { // 限制之前 < 之后 > ,下面同理 if (new Date().getMinutes() <= i) continue; a.push(i); } return a; }; const disabledSeconds = () => { const a = []; for (let i = 0; i < 60; i++) { // 限制之前 < 之后 > ,下面同理 if (new Date().getSeconds() <= i) continue; a.push(i); } return a; };
/** js */
标签:同理,const,++,Element,Date,日期,let,组件,new From: https://www.cnblogs.com/lys597/p/17461087.html