index.js
import React from 'react';
import ReactDOM from 'react-dom';function Childcom(props) {console.log(props)let title = < h2 > 我是副标题 < /h2>let weather = "下雨"let isGo = weather == '下雨' ? "不出门" : "出门"return ( <div ><h1 > 函数式组件 helloworld < /h1> { title } <div >是否出门? <span > { isGo } < /span> < /div ></div >)
}
class HelloWorld extends React.Component {render() {console.log(this)return ( <div ><h1 >类组件定义HELLOWORLD </h1> <Childcom / ></div >)}
}ReactDOM.render( <HelloWorld name = "geyap" / > ,document.querySelector('#root')
)
运行结果