elementUI 时间控件控制时间选择

选择时间大于当前月或小于2024年一月禁止选择

html 复制代码
						<el-form-item label="成交月份:" label-width="105px" >
                            <div class="block">
                                <el-date-picker
                                        v-model="formData.deal_month"
                                        type="month"
                                        :picker-options="pickerOptions"
                                        placeholder="选择月">
                                </el-date-picker>
                            </div>
                        </el-form-item>
javascript 复制代码
data: {
            
            pickerOptions: {
                disabledDate(time) {
                    const now = new Date();
                    const currentYear = now.getFullYear();
                    const currentMonth = now.getMonth();
                    const startOfMonth2024 = new Date(2024, 0, 1); // 2024年1月1日

                    // 禁用小于2024年1月或大于当前月份的日期
                    return time.getTime() < startOfMonth2024.getTime() || time.getFullYear() > currentYear || (time.getFullYear() === currentYear && time.getMonth() > currentMonth);
                }
            },
        },
相关推荐
PineappleCoder21 小时前
性能数据别再瞎轮询了!PerformanceObserver 异步捕获 LCP/CLS,不卡主线程
前端·性能优化
PineappleCoder21 小时前
告别字体闪烁 / 首屏卡顿!preload 让关键资源 “高优先级” 提前到
前端·性能优化
m0_4711996321 小时前
【vue】通俗详解package-lock文件的作用
前端·javascript·vue.js
GIS之路1 天前
GDAL 读取KML数据
前端
今天不要写bug1 天前
vue项目基于vue-cropper实现图片裁剪与图片压缩
前端·javascript·vue.js·typescript
用户47949283569151 天前
记住这张时间线图,你再也不会乱用 useEffect / useLayoutEffect
前端·react.js
咬人喵喵1 天前
14 类圣诞核心 SVG 交互方案拆解(附案例 + 资源)
开发语言·前端·javascript
问君能有几多愁~1 天前
C++ 日志实现
java·前端·c++
咬人喵喵1 天前
CSS 盒子模型:万物皆是盒子
前端·css