antd日期選擇器禁止選擇當天之前的時間


官方網站中組件的介紹

https://www.antdv.com/components/calendar-cn/#API

 

使用disabledDate屬性(不可選擇的日期)

<a-date-picker @change="dateChange" :disabledDate="disabledDate" v-decorator="['endDate']"/>

  

 在js中定義函數並返回

 

 //限制當天之前的日期不可選
      disabledDate(current) {
        return current && current <moment().subtract(1, "days"); //當天之前的不可選,不包括當天
        //return current && current < moment().endOf(‘day’);當天之前的不可選,包括當天
      },

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM