<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="root"></div>
<script src="../lib/react.js"></script>
<script src="../lib/react-dom.js"></script>
<script src="../lib/babel.js"></script>
<script type="text/babel">
let message = "Hello World"
function btnClick(){
message = "Hello React"
rootRender()
}
const root = ReactDOM.createRoot(document.querySelector("#root"))
function rootRender() {
root.render((
<div>
<h2>{message}</h2>
<button onClick={btnClick}>修改文本</button>
</div>
))
}
rootRender()
</script>
</body>
</html>
文章来源地址https://www.toymoban.com/news/detail-587908.html
文章来源:https://www.toymoban.com/news/detail-587908.html
到了这里,关于03_Hello_React重构的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!