首页 > 解决方案 > 禁用未来日期引导 vue datepicker

问题描述

我正在使用 bootstrap-vue 插件。我想禁用 bootstrap-vue datepicker 的未来日期。

这是我的代码:

<b-form-datepicker :date-disabled-fn="disabledDates" v-model="form.date_of_birth" placeholder="Select Date"/>

在 Js 部分:

methods: {
      dateDisabled(ymd, date) {
        // Disable weekends (Sunday = `0`, Saturday = `6`) and
        // disable days that fall on the 13th of the month
        const weekday = date.getDay()
        const day = date.getDate()
        // Return `true` if the date should be disabled
        return weekday === 0 || weekday === 6 || day === 13
      }
    }

它正在禁用周末和每月 13 日。但我想禁用所有未来的日期。

根据他们的文件:

The function should either return true if the date cannot be selected (disabled), or false if the date can be selected (enabled). Note that the function cannot be asynchronous, and should return a value as quickly as possible.

我无法制定返回未来日期的逻辑。我怎样才能做到这一点?

标签: javascriptvue.jsdatepickerbootstrap-vue

解决方案


推荐阅读