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);
                }
            },
        },
相关推荐
计算机魔术师17 小时前
Anthropic IPO 招股文件披露近 9000 亿美元隐性债务
前端
Hello.Reader17 小时前
Three.js / Cesium 卡顿怎么办?把三维渲染搬到 GPU 服务器
服务器·开发语言·javascript
chi113017 小时前
【无标题】
前端·javascript·python
萝卜兔00818 小时前
PIKACHU_UnsafeFileUpload
javascript·php
IT_陈寒18 小时前
JavaScript实战技巧总结:深挖数组遍历的性能陷阱与实战解法
前端·人工智能·后端
步行cgn18 小时前
为什么既要 web.xml 又要 springmvc.xml?能不能只配一个?
xml·前端·hive
风骏时光牛马18 小时前
大模型综合能力评测:多维度性能与对齐效果对比
前端
winfredzhang18 小时前
从零手写一个毛玻璃风格的页面搭建台:单文件 HTML 实现组件放置、面板磁吸与图层管理
前端·html
葡萄城技术团队1 天前
1000 人协同压测的环境瓶颈排查:CPU 争用与 Wi\-Fi
前端
excel1 天前
Marked 与 Markdown 有什么区别?该怎么选?
前端