<div id="app"></div>
HTML
格式化
支持Emmet,输入 p 后按 Tab键试试吧!
<head> <!-- 引入 react@16.14 -->
... </head>
<body>
</body>
CSS
格式化
html {
height: 100%;
}
body {
height: 100%;
background: #212121;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
}
JS
格式化
var root = document.createElement("div");
root.id = "root"
const App = React.forwardRef(() => {
const [browsers, setData] = React.useState(
["Firefox", "Chrome", "Opera", "Safari", "Internet Explorer"]
);
React.useEffect(() => {
console.log("useEffect"),
setTimeout(() => {
console.log("useEffect2")
setData(["dadfds","12313"]);
}, 1000)
}, [])
function handleClick() {
// alert('你点击了我11!');
setData(["ccccc","dddddd"]);
}
return <div>
{browsers.map((browser) => <div key={browser}>{browser}</div>)}
<button onClick={handleClick}>
点我
</button>
</div>
})
ReactDOM.render(<App />, root);
document.body.appendChild(root);