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);
                }
            },
        },
相关推荐
aiwery3 分钟前
大模型场景下的推送技术选型:轮询 vs WebSocket vs SSE
前端·agent
会豪5 分钟前
前端插件-不固定高度的DIV如何增加transition
前端
却尘5 分钟前
Server Actions 深度剖析(2):缓存管理与重新验证,如何用一行代码干掉整个客户端状态层
前端·客户端·next.js
小菜全5 分钟前
Vue 3 + TypeScript 事件触发与数据绑定方法
前端·javascript·vue.js
Hilaku8 分钟前
面试官开始问我AI了,前端的危机真的来了吗?
前端·javascript·面试
zheshiyangyang19 分钟前
TypeScript学习【一】
javascript·学习·typescript
shellvon1 小时前
前端攻防:揭秘 Chrome DevTools 与反调试的博弈
前端·逆向
β添砖java1 小时前
案例二:登高千古第一绝句
前端·javascript·css
却尘1 小时前
Server Actions 深度剖析:这就是个披着 React 外衣的 RPC
前端·rpc·next.js
TNTLWT1 小时前
单例模式(C++)
javascript·c++·单例模式