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

如何将MUI DesktopDateTimePicker的时间选择器改为DigitalClock(仅桌面端)

解决MUI DesktopDateTimePicker切换为数字时钟(DigitalClock)的方法

要把桌面端的DateTimePicker时间选择视图从模拟时钟改成数字时钟,只需要给DesktopDateTimePicker添加components属性,指定时间选择器组件为DigitalClock即可,步骤如下:

  1. 先导入DigitalClock组件:
import { DigitalClock } from '@mui/x-date-pickers/DigitalClock';
  1. 修改你的DesktopDateTimePicker代码,添加components配置:
<DesktopDateTimePicker
  {...rest}
  {...field}
  inputRef={ref}
  disabled={disabled}
  inputFormat="dd.MM.yyyy HH:mm"
  // 指定时间选择器为数字时钟
  components={{
    TimePicker: DigitalClock
  }}
  renderInput={(inputProps) => (
    <TextField
      {...inputProps}
      error={!!error}
      onBlur={onBlur}
      helperText={error?.message}
    />
  )}
/>

这样设置后,当你选择完日期进入时间选择环节时,就会显示数字时钟(DigitalClock)而非默认的模拟时钟了。

内容的提问来源于stack exchange,提问作者Petter Jørgensen

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.12 01:11:10