import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import { tsPropertySignature } from '@babel/types';//<app/>js的普通对象
/*let app = < App / >let root = document.getElementById('root')let h1=<h1>helloworld<span>我是</span></h1>
{ ReactDOM.render(h1, root
); }*/
//实现时刻的变化
/* function clock() {let time = new Date().toLocaleTimeString()let element = ( < div > < h1 > 现在的时间 { time } < /h1></div > )let root = document.querySelector('#root')ReactDOM.render(element, root)
}
clock()setInterval(clock, 1000) *//* function Clock(props) {return (<div ><h1 > 现在的时间是 { props.date.toLocaleTimeString() } < /h1> <h2 > 这是副标题 < /h2> < /div >)}function run() {ReactDOM.render( <Clock date = { new Date }/>, document.querySelector('#root'))
}setInterval(run, 1000) */
let time = new Date().toLocaleTimeString()
let str = '当前时间是:'
let element = ( <div ><h1 > helloworld < /h1> <h2 > { str + time } < /h2> < /div >
)
let man = "发热"
let element2 = ( <div ><h1 > 今天是否隔离 < /h1> <h2 > { man == "发热" ? "隔离" : "躺床上" } < /h2> < /div >
)/* ReactDOM.render(element, document.querySelector('#root')
) */
ReactDOM.render(element2, document.querySelector('#root')
)
运行结果