简体   繁体   English

如何禁用ion-datetime中的特定日期?

[英]How to disable specific day in ion-datetime?

我已经查看了官方文档,但我无法找到,我需要一个函数或类似jquery datepicker beforeshowday函数之类的东西,我只想在所有即将到来的日期中禁用所有周末(周六,周日),以便用户可以' t选择哪些日期属于星期六和星期日我正在使用离子v3

I'm not sure you can disable a specific day with the ion-datetime component. 我不确定您是否可以使用ion-datetime组件禁用特定日期。

But you can check the library ion-datepicker where you can disable specific dates. 但您可以检查库ion-datepicker ,您可以在其中禁用特定日期。

You also need to create a function that contains the weekends date you want disable. 您还需要创建一个包含要禁用的周末日期的函数。

From their documentation: 从他们的文件:

"[disabledDates] - An array of dates that should be disabled (not required)" “[disabledDates] - 应禁用的日期数组(不是必需的)”

for instance in a home page: 例如在主页中:

    //declare it in home.ts
        public disabledDates: Date[] = [new Date(2017, 7, 14)];

        //and use it in home.html
    <span ion-datepicker  [(value)]="localDate [disabledDates]="disabledDates" clear class="ScheduleDate">
        <span>{{localDate | date}} <ion-icon name="clipboard" item-left ></ion-icon> </span>
    </span>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM