We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import React from 'react'; import { DatePicker } from '@ies/semi-ui-react'; import * as dateFns from 'date-fns'; class App extends React.Component { constructor(props = {}) { super(props); this.today = () => new Date(); this.disabledTime = date => dateFns.isToday(date) ? { disabledHours: () => [17, 18], } : null; } render() { return ( <div> <h4>禁用时间:禁用今天下午5-6点</h4> <DatePicker type="dateTime" hideDisabledOptions={false} disabledTime={this.disabledTime} /> </div> ); } }
The text was updated successfully, but these errors were encountered:
目前的交互行为不好用。disabledTime 只对时间生效,无法控制日期是否可以选择。可以先通过下面的方式实现这个目标 o(╥﹏╥)o
() => { const [value, setValue] = useState(); const disabledTime = date => dateFns.isToday(date) ? { disabledHours: () => [17, 18], } : null; const disabledDate = date => { const h = dateFns.isDate(value) && value.getHours() || 0; const d = date.getDate(); console.log(d, h); if (dateFns.isToday(date) && [17, 18].includes(h)) { return true; } else { return false; } }; const handleChange = (date) => { setValue(date); }; return ( <div> <h4>禁用时间:禁用今天下午5-6点</h4> <DatePicker type="dateTime" onChange={handleChange} disabledDate={disabledDate} disabledTime={disabledTime} /> </div> ); }
Sorry, something went wrong.
建议优化 disabledDate 逻辑,如果已选时间在禁用范围内,则日期也不可选(For Semi RD)。
shijiatongxue
No branches or pull requests
Which Component 出现bug的组件
semi-ui version
Expected result 期望的结果是什么
Actual result 实际的结果是什么
Steps to reproduce 复现步骤
Reproducible code 复现代码
Additional information 补充说明
The text was updated successfully, but these errors were encountered: