import React form 'react'import ReactDom from'react-dom'// {}可以写变量、算数、三元表达式 不能写for、if这些语句let name ='呼呼'let age =18let div =<div><h1>我是div里面的h1标签</h1><div>{name}</div><h2>{1+1}</h2><h3>{age >=18?'已成年':'未成年'}</h3></div>
console.log(name)
ReactDom.render(div, document.getElementById('root'))
import React form 'react'import ReactDom from'react-dom'import'./style/index.css'let div =<div className='box'>我是一个小哈哈</div>
ReactDom.render(div, document.getElementById('root'))
if条件渲染
import React form 'react'import ReactDom from'react-dom'// react中的if条件渲染:就是原生js的if直接判断let isLoading =falselet div =''if(isLoading){
div =<div><h3>加载中...</h3></div>}else{
div =<div><h3>加载完成</h3></div>}
ReactDom.render(div, document.getElementById('root'))