我正在尝试获取 Date.now(); 当按下回车键但我收到错误消息时。:(
网上似乎也没有很多关于这个错误的信息。
export class DashboardComponent implements OnInit {
onEnter(event){
if(event.key === "Enter"){
this.calculateTime();
}
}
calculateTime(){
if(this.date === undefined){
this.date = new Date.now();
}
}
}
Run Code Online (Sandbox Code Playgroud)
错误是:
错误 TS2350:只能使用“new”关键字调用 void 函数。
知道为什么我会收到此错误以及如何修复它吗?
啦啦队。