javascript - Enable only year in Material-UI DatePicker with react - Stack Overflow

I'm having trouble with trying to enable a Material-UI DatePicker to only receive year, the user w

I'm having trouble with trying to enable a Material-UI DatePicker to only receive year, the user won't be able to put or select month and day. I've already tried some options, but is still not working. Anybody have a solution for this?

I'm having trouble with trying to enable a Material-UI DatePicker to only receive year, the user won't be able to put or select month and day. I've already tried some options, but is still not working. Anybody have a solution for this?

Share Improve this question asked Aug 12, 2019 at 16:19 Hiago ReisHiago Reis 211 silver badge2 bronze badges 2
  • I've already tried some options, but is still not working What other options did you try? :) – Sharon Commented Aug 12, 2019 at 16:28
  • Hi! Try to be more specific to your issue by adding an example on code you trying to solve. – Lucho Commented Aug 12, 2019 at 16:29
Add a ment  | 

1 Answer 1

Reset to default 6

There is a prop called views which is exactly for this purpose. It receives an array of types that should be rendered:

Array<"year" | "date" | "month">

So just pass year to it:

<DatePicker views={['year']} />

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745371725a4624823.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信