当前位置:网站首页>【typescript】使用antd中RangePicker组件实现时间限制 当前时间的前一年(365天)
【typescript】使用antd中RangePicker组件实现时间限制 当前时间的前一年(365天)
2022-08-02 13:02:00 【Sco_Jing1031】
//先导入组件
import {
DatePicker } from 'antd';
import moment from 'moment';
const {
RangePicker } = DatePicker;
/**操作时间下拉项 */
const renderTimeSelect = () => {
/**可选范围为最近一年 */
const disabledDate = (m: Moment) =>
(m && m.isAfter(moment().endOf('day'))) ||
(m &&
m.isBefore(
moment()
.subtract(1, 'year')
.startOf('day'),
));
return (
<Form.Item label="操作时间">
{
getFieldDecorator('operationTime', {
initialValue: [
moment()
.subtract(30, 'days')
.startOf('day'),
moment(),
],
})(
<RangePicker
allowClear={
false}
showTime
format="YYYY-MM-DD HH:mm"
disabledDate={
disabledDate as any}
onOk={
() => {
LX(get(operationRecordLx, `operationTime.${
source}`));
}}
/>,
)}
</Form.Item>
);
};
边栏推荐
猜你喜欢
PHP+MYSQL [Student Information Management System] (Minimalist Edition)
php - the first of three solid foundations
First acquaintance of scrapy framework 1
How to better assess credit risk?Just watch this scorecard model live
FreeRTOS--优先级实验
Singleton pattern of seven kinds of writing, you know?
路由-嵌套路由
吾爱第三课-修改版权和资源
To eliminate air bubbles to save the mushroom h5 small game source code
LeetCode_377_Combination Sum IV
随机推荐
svg balloon rises explosion js special effect
移动端适配,华为浏览器底色无法正常显示
zabbix automated monitoring script
Introduction to Graph Neural Networks (GNN) "Recommended Collection"
瀑布流式布局怎么实现(什么是瀑布流布局)
js cool dashboard plugin
麻烦问一下,对mysql 场景注入故障,是不是不是对mysql server 端注入故障,只是对ja
How to turn off hardware acceleration [easy to understand]
The uniapp/applet onload method executes the interpretation every time the page is opened
SQL中字符串拼接
节省50%成本!京东云重磅发布新一代混合CDN产品
Win11怎么修改关机界面颜色?Win11修改关机界面颜色的方法
单例模式的七种写法,你都知道吗?
工厂方法模式
svg实现的树木四季变化
Singleton pattern of seven kinds of writing, you know?
svg气球升起爆炸js特效
Mysql视图
JS中的闭包
你知道图论的spfa吗?