我试图在离子中获取日期的小时和分钟,但出现错误。
这是我的 .html 文件中的代码:
<ion-datetime displayFormat="HH:mm" [(ngModel)]='timeEntered1' picker-format="h:mm"></ion-datetime>
<ion-button (click)="getTime()"></ion-button>
然后在我的 .ts 文件中,我有这个:
timeEntered1 = new Date();
constructor() {}
getTime() {
console.log(this.timeEntered1.getHours());
}
我的错误是:
this.timeEntered1.getHours 不是函数