共计 828 个字符,预计需要花费 3 分钟才能阅读完成。
template
<el-date-picker
v-model="timing"
type="datetime"
:disabled-date="disableConfig"
:disabled-hours="disabledHours"
:disabled-minutes="disabledMinutes"
:disabled-seconds="disabledSeconds"
/>
限度以后工夫之前的工夫
/* 限度天 */
export const disableConfig = (time) => {return time.getTime() < Date.now()}
/* 限度时 */
export const disabledHours = () => {const arrs = []
for (let i = 0; i < 24; i++) {
// 限度之前 < 之后 >,上面同理
if (new Date().getHours() <= i) continue;
arrs.push(i)
}
return arrs;
}
/* 限度分 */
export const disabledMinutes = () => {const arrs = []
for (let i = 0; i < 60; i++) {if (new Date().getMinutes() <= i) continue;
arrs.push(i)
}
return arrs;
}
/* 限度秒 */
export const disabledSeconds = () => {const arrs = []
for (let i = 0; i < 60; i++) {if (new Date().getSeconds() <= i) continue;
arrs.push(i)
}
return arrs;
}
限度之后的工夫
export const setDisableDate = (time) => {
return (time.getTime() < new Date().getTime() - 24 * 60 * 60 * 1000 * 365 * 2 ||
time.getTime() > new Date().getTime())
}
正文完