class Clock extends React.Component {
render() {
return (
<div>
<h1>Hello, world!</h1>
<h2>现在是 {this.props.date.toLocaleTimeString()}.</h2>
</div>
);
}}
function tick() {
ReactDOM.render(
<Clock date={new Date()} />, //clock就是上面创建的组件,拿来当标签使用 ,它里边的属性既是传的参数props
document.getElementById('example')
);}
setInterval(tick, 1000);