有没有办法禁止在日期输入中键入/粘贴,而只允许用户从 AntD 中的日期选择器中进行选择? [英] Is there a way to disable typing/pasting into the date input and only allowing users to select from the date picker in AntD?
本文介绍了有没有办法禁止在日期输入中键入/粘贴,而只允许用户从 AntD 中的日期选择器中进行选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法禁止在日期输入中输入/粘贴,而只允许用户从 AntD 的日期选择器中进行选择?禁用也不起作用.我已经浏览了
styles.css.(你只需要在你的 .css
文件中添加这个 css)
.ant-calendar-input-wrap {显示:无;}
App.js
render() {返回 (<div className="应用程序"><DatePicker/>
);}
Is there a way to disable typing/pasting into the date input and only allowing users to select from the date picker in AntD? disabling doesn't work either. I've gone through the documentation I tried this way
import { DatePicker } from 'antd';
...
handleDateChange = (e) => {
e.preventDefault();
}
...
render() {
...
<DatePicker onChange={this.handleDateChange} ... />
...
}
This way it just stopped taking input values even through picker panel.
解决方案
For antd date picker, you need to set dispaly: none
in ant-calendar-input-wrap
class.
styles.css. (You just only need to add this css in your .css
file)
.ant-calendar-input-wrap {
display: none;
}
App.js
render() {
return (
<div className="App">
<DatePicker />
</div>
);
}
这篇关于有没有办法禁止在日期输入中键入/粘贴,而只允许用户从 AntD 中的日期选择器中进行选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文