1
ich einen Fehler wie folgt festgestellt:undefiniert ist kein Objekt (Bewertung '_this.props.date.getFullYear')
und das ist mein Code
export default class StarView extends Component{
static propTypes = {
date : React.PropTypes.instanceOf(Date)
}
constructor(props){
super(props);
this.state = {
selectedYear: this.props.date.getFullYear(),
selectedMonth: this.props.date.getMonth(),
selectedDate: this.props.date.getDate(),
yesterdayYear : new Date(this.props.date.getTime() - 24 * 3600 * 1000).getFullYear(),
yesterdayMonth: new Date(this.props.date.getTime() - 24 * 3600 * 1000).getMonth(),
yesterdatDate : new Date(this.props.date.getTime() - 24 * 3600 * 1000).getDate(),
tomorrowYear : new Date(this.props.date.getTime() + 24 * 3600 *1000).getFullYear(),
tomorrowMonth : new Date(this.props.date.getTime() + 24 * 3600 *1000).getMonth(),
tomorrowDate : new Date(this.props.date.getTime() + 24 * 3600 *1000).getDate()
}
}}
Ich mag Holen Sie sich eine Standard-Daten von this.props.date, aber ich weiß nicht, warum ich den Fehler
Bitte zeigen Wie geht es Ihnen 'vorbei date' –
prop wie sind vorbei Sie Datum als Stütze auf die Starview Komponente –
die console.log setzen (Requisiten) in Konstruktor und fügen Sie den Ausgang in ur ques. –