class Date extends React.Component {
getMonthList(){
let date = new Date();
let startYear = 2000
let currentYear = date.getFullYear()
let items = []
for(let i=currentYear; i>=startYear; i--){
items.push(<li>{i}</li>)
}
return <ul>{items}</ul>
}
render() {
return (
<div>{this.getMonthList()}</div>
)}
}
Reference
https://ithelp.ithome.com.tw/articles/10201227
No comments :
Post a Comment