javascript - 如何禁用今天的日期和日期选择器默认是第二天
问题描述
我正在尝试创建一个返回打开日期选择器的函数,它将返回今天日期的第二天,例如:今天的日期是 2021 年 10 月 1 日,所以第二天是 2021 年 10 月 2 日。
这是我的代码库:
openToDate(val:any){
console.log("val: ", val)
return moment(val).toDate();
}
<DatePicker
customInput={
<React.Fragment>
<input
tabIndex={this.props.tabIndex}
className="exact-date-input"
placeholder={this.props.placeholder}
autoComplete="off"
type="text"
maxLength={10}
id="date-input"
aria-label={ariaLabel}
value={this.state.inputValue}
onKeyDown={this.onKeyDownDateType}
onClick={()=>this.openOrCloseDatePicker(true, this.state.error)}
onFocus={()=>this.openOrCloseDatePicker(true, this.state.error)}
onBlur={()=>this.emptyIfError(this.state.error)}
/>
</React.Fragment>
}
openToDate={this.openToDate(this.props.value)}
tabIndex={-1}
selected={this.openToDate(this.props.value)}
customInputRef="dateInput"
autoComplete="off"
id={this.props.id}
onChange={this.handleInput}
required={this.props.required}
minDate={moment(today).toDate()}
maxDate={moment(endRange).toDate()}
open={this.state.datePickerIsOpen}
onClickOutside={()=>this.openOrCloseDatePicker(false, this.state.error)}
/>
解决方案
推荐阅读
- sql - 使用来自同一来源的两个不同列创建一个表/视图
- javascript - PageYOffset 说明
- javascript - Javascript / HTML在鼠标单击时将照片添加到中心位置
- api - Roundcube休息api
- java - 转换列表
- > 流式传输
> - asp.net-core - 我可以在 AspNetCore WebAPI 中将 CancellationToken 作为参数传递吗
- flutter - 如何在 Flutter 中制作 Font Family Fallback?
- python - 如何在函数循环之外定义参数?
- node.js - 如何通过单击外部菜单和菜单项来关闭“react-burger-menu”
- android - 如何在 Android Studio 4.1 中默认启用 Kotlin Android 扩展