-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
55 lines (48 loc) · 1.69 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!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="https://unpkg.com/react@18/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js" crossorigin></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js" crossorigin></script> -->
<script src="../../.lib/[email protected]" crossorigin></script>
<script src="../../.lib/[email protected]" crossorigin></script>
<script src="../../.lib/[email protected]" crossorigin></script>
</body>
<script type="text/babel">
const styleObj = {
color: '#f40',
backgroundColor: 'antiquewhite'
}
document.body.insertAdjacentHTML(
`
<style>
.test {
background-color: antiquewhite;
}
</style>
`
)
function MyApp() {
return (
<main>
<h1 className="test">welcome to my app! --- h1 - 1</h1>
<h2 style={{ color: '#fff', backgroundColor: '#000' }}>H2</h2>
<h2 style={styleObj}>H2</h2>
</main>
) // 编辑器渲染错误,实际代码没问题
}
// 渲染到页面上
// 获取根元素
const rootEl = document.getElementById('root')
// 创建 ReactDOM 根实例
const rootIns = ReactDOM.createRoot(rootEl)
// 使用根实例渲染组件
rootIns.render(React.createElement(MyApp))
</script>
</html>