el-date-picker如果超过限制跨度则提示
发布时间:2024年01月17日
需求:实现日期时间选择组件跨度如果超过限制天数,点击查询则提示超过限制时间

封装一个方法,传入开始和结束时间以及限制天数,如果超过则返回false
//计算时间跨度是否超过限制天数
isTimeSpanWithinLimit(startTime, endTime, limitDays) {
const startDateTime = new Date(startTime)
const endDateTime = new Date(endTime)
const timeDifference = endDateTime - startDateTime
const daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24))
return daysDifference <= limitDays
}
文章来源:https://blog.csdn.net/wyq12138/article/details/135656585
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:chenni525@qq.com进行投诉反馈,一经查实,立即删除!