1、React介绍和快速体验
使用create-react-app创建项目:
npx reate-react-app 项目名
启动项目:npm start
2、开发环境搭建
只保留index.js文件
清空index.js的内容
3、react初体验
渲染一个h1元素,内容为hello react
// 1、导包
import { createRoot } from 'react-dom/client'
// 2、创建根对象
const root = createRoot(document.querySelector('#root'))
// 3、渲染react内容
// <h1>hello,react</h1> => JSX 写在js中html
root.render(<h1>hello,react</h1>)