更改MUI DatePicker对话框的OK文字
如何将datepicker对话框按钮从确定更改为诸如应用之类的内容。 MUI文档没有提供任何帮助我更改标题的道具
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何将datepicker对话框按钮从确定更改为诸如应用之类的内容。 MUI文档没有提供任何帮助我更改标题的道具
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
我正在使用MUI的datepicker v5,以下对我有用:
来自我的软件包的版本:
“@mui/x-date-pickers”:“^5.0.16”,
您可以通过指定
componentsProps
datePicker
在datePicker的日历对话框上指定哪些按钮。显示的按钮的顺序遵循传递给componentsprops-> actionbar-> action
的序列。在这种情况下,按钮的顺序将是:取消,清除,接受,今天。您可以通过将
localeText
传递给lotization provider的按钮上的标签:,所以您会看到这一点日历对话框中的按钮:
退出,无,保存,设置
I'm using MUI's datepicker v5, the below works for me:
version from my package.json:
"@mui/x-date-pickers": "^5.0.16",
You can specify which buttons are displayed on the datepicker's calendar dialog by specifying the
componentsProps
fordatepicker
. The sequence of the buttons displayed follows the sequence in the array passed tocomponentsProps->actionBar->actions
. In this case, the order of buttons will be: cancel, clear, accept, today.You can change the label on the buttons by passing in
localeText
to the LocalizationProvider:<LocalizationProvider localeText={{ cancelButtonLabel: 'Exit', clearButtonLabel: 'None', okButtonLabel: 'Save', todayButtonLabel: 'Set today' }}>
So you will see this buttons in the calendar dialog:
Exit, None, Save, Set today
您只需将
俄克拉牌
提供给您的datepicker组件即可。You can simply pass
okLabel
prop to your datepicker component.