2017-04-12 72 views

回答

8

试试这个:

<input class="alert-input date-input" name="dob" [max]="today" type="date"> 


today = new Date().toJSON().split('T')[0]; 

Working Example Demo

原因:

Becasue当您使用new Date()这会给你充分的时间与时区和时间等,您必须仅指定日期,因此您必须仅用日期来分割此日期。 为更多clerification运行此

console.log(new Date(), '----', new Date().toJSON()); 
+1

太棒了! :) 谢谢。 –

相关问题