工程结构和模块化
创建组件
在src目录下新建目录components,如果要创建Hello组件,便创建文件夹Hello,创建文件
index.jsxindex.css
CSS样式模块化
为了防止组件之间的样式冲突,可以在组件文件下的样式文件index.css改为index.module.css文件,这样原本的导入语句:
import "./index.css"就可以改为:
import hello from "./index.css"
// 在使用时,就不可直接使用css样式名称了
<h1 className={hello.title}></h1>最后更新于
这有帮助吗?