jeecgboot vue3使用DatePicker组件设置可用日期

文档: Ant Design Vue文档

设置不能选择今天之前的日期

(1)使用表单的formSchema中的componentProps组件属性通过disabledDate设置

import dayjs, {Dayjs} from "dayjs";

  {
    label: '日期',
    field: 'guidDate',
    component: 'DatePicker',
    dynamicRules: ({model, schema}) => {
      return [
        {required: true, message: '请输入日期!'},
      ];
    },
    componentProps: ({formModel}) => {
      return {
        format: 'YYYY-MM-DD',
        disabledDate: (current: Dayjs) => {
          return current && current < dayjs().add(-1, 'day').endOf('day');
        },
      }
    }
  },

(2)使用插槽slot方式实现

 {
      field: 'guidDate',
      label: '起保日期',
      slot: 'customSlot', //设置slot的值
      component: 'DatePicker',
      rules: [{required: true, message: '日期不能为空'}],
  }
   
     
    


/*开始时间*/
import dayjs, {Dayjs} from "dayjs";
const disabledDate = (current: Dayjs) => {
  return current && current < dayjs().add(-1, 'day').endOf('day');
};

你可能感兴趣的:(#,前端记录,vue.js,jeecgboot)