学习React02

90 阅读1分钟

在index.js中写例子

//React函数式组件 函数名作为组件要大写
function NowTimeShow(props) {
  return (
    <div>
      <h1>现在时间{props.date}</h1>
      <h2>函数式组件开发 </h2>
    </div>
  )
}

function runDom() {
  ReactDOM.render(
    <NowTimeShow date={new Date().toLocaleTimeString()} />,
    document.querySelector('#root')
  )
}
setInterval(runDom, 1000)