<script type="text/babel">
class Time extends React.Component {
state = {
date: new Date()
}
componentDidMount () {
setInterval(() => {
this.setState({
date: new Date()
})
}, 1000)
}
render() {
return (
<div>
<h1>Hello</h1>
<span>现在是{this.state.date.toTimeString()}</span>
</div>
)
}
}
ReactDOM.render(<Time />,document.querySelector("#app"))
</script>
验证diffing算法
最新推荐文章于 2024-08-29 11:24:16 发布