【问题标题】:Material UI - How a Date Picker could only select month/yearMaterial UI - 日期选择器如何只能选择月/年
【发布时间】:2019-03-28 03:18:54
【问题描述】:

我在一个项目中使用 MaterialUI,我需要一个只能选择月份和年份的日期选择器 (https://material-ui.com/demos/pickers/),我应该使用什么道具来实现这一点?

【问题讨论】:

    标签: reactjs forms material-ui


    【解决方案1】:

    Material UI 日期选择器文档指定您可以使用自定义渲染器here

    这是自定义渲染器的codesandbox。您也许可以使用带有 format 属性的自定义渲染器来实现您正在寻找的东西。

    【讨论】:

      【解决方案2】:

      这里的所有链接都是无效的,所以我想快速总结一下这个问题,Material UI 有一个简单的功能可以满足你现在需要的功能(使用DatePicker 组件),参考官方文档: https://mui.com/components/date-picker/#views-playground

      Codesandbox example here

      如您所见,添加: 浏览量={['年', '月']} DatePicker 的属性可以解决问题!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-08-30
        • 1970-01-01
        • 1970-01-01
        • 2021-12-15
        • 2011-05-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多