❤️ 创建项目
- webstorm 创建 vite 项目,选择 react 模板
app.jsx
项目的根组件,是一切组件的根基
jsx
function App() {
return (
<>
<div>
this is a test
</div>
</>
)
}
export default Appmain.jsx
jsx
import {createRoot} from 'react-dom/client'
import App from './App.jsx'
// 找到 id 为 root 的元素,然后渲染 App 组件
createRoot(document.getElementById('root')).render(
<App />
)❤️ 调式
- 安装浏览器插件
React Developer Tools进行调试