You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

dxDateBox选择最小时间选项时提示Value is out of range问题咨询

DevExtreme dx-date-box 选择min边界值触发范围错误提示问题

组件配置代码

<dx-date-box
  useMaskBehavior="true"
  [min]="now"
  [max]="generalMaxDate"
  type="time"
></dx-date-box>

绑定的TS数据

now: Date = new Date();
generalMaxDate: Date = new Date('3000-01-01');

问题现象

按上述配置使用组件时,首次选择min对应的当前时间选项,组件会弹出Value is out of range的提示信息,该问题在DevExtreme最新Demo及旧版本示例中均可复现。

问题原因

这是dx-date-box组件在启用useMaskBehavior且类型为time时的边界值校验bug:

  • min设置的当前时间是精确到毫秒的完整时间戳
  • 时间选择器提供的选项仅精确到秒(或更低精度),选择后的值会被截断到该精度,导致实际值略小于min的毫秒级数值,触发范围校验失败。

比如min是2024-05-20 14:30:45.123,选择器选项是14:30:45,绑定后的值为2024-05-20 14:30:45.000,比min小123毫秒,因此被判定为超出范围。

临时解决方案

  1. 将min的精度向下取整到选择器的精度级别(比如秒):
    now: Date = new Date(Math.floor(new Date().getTime() / 1000) * 1000);
    
  2. 若业务允许,关闭useMaskBehavior属性

内容的提问来源于stack exchange,提问作者pycxu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 03:57:41