OGeek|极客世界-中国程序员成长平台

标题: android - Ionic2 日期时间从最小日期开始 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 18:47
标题: android - Ionic2 日期时间从最小日期开始

我有一个仅显示年份的 ionic 日期时间:

<ion-datetime displayFormat="YYYY" min=2017 max=2050></ion-datetime>

但是当我打开这个选择器时,年份从 2050 年开始,我想从 2017 年开始。

enter image description here

有什么方法可以从最小值开始到最大值?



Best Answer-推荐答案


From Ionic framework docs DateTime Component

您必须在组件文件中设置日期对象或简单的字符串值以显示选定的年份。

例如,如果您想从当前日期对象中显示选定的年份,那么

public mTodayDate: any = new Date().toISOString();

例如,如果您想显示选定的年份“2020”,那么

public mTodayDate: any = "2020";

<ion-datetime displayFormat="YYYY" min="2017" max="2050 [(ngModel)]="mTodayDate"></ion-datetime>

关于android - Ionic2 日期时间从最小日期开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41965602/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4