我使用 react-day-picker(DayPickerInput 组件),我希望当用户点击相关字段时,当日期选择器窗口打开时,用户将无法使用键盘输入值,并且他可以通过弹出窗口更改值。
我不知道这是一个DayPickerInput的属性(我搜索了没找到),还是字段本身的通用属性...
最佳答案
好的, 我只需要像这样添加 readOnly:
<DayPickerInput
readOnly // just it!!
dayPickerProps={{localeUtils: MomentLocaleUtils, locale:"he"}}
className={theme.dayPicker}
placeholder={this.props.hintText}
value={value}
onDayChange={(date: moment.Moment) => this.handleChange(date.toDate())}>
</DayPickerInput>
(
关于javascript - 如何不允许用户在带有选择选项的输入字段中输入值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47529079/