【文件属性】:
文件名称:react-scoped-styles:React的作用域样式
文件大小:9KB
文件格式:ZIP
更新时间:2021-03-18 05:39:37
react scoped styles TypeScript
React的作用域样式
获取由组件目录界定CSS类
它与CSS模块有何不同?
在CSS模块中,您必须手动导入和分配类
import styles from './button.styl' ;
const Button = ( ) => (
< button className = { styles . foo } > Press Me < / button >
) ;
React Scoped Styles不需要更改常规的样式工作流程。您仍然使用纯字符串分配类。
import './button.styl' ;
const Button = ( ) => (
< button className = "foo" > Press Me < / button >
) ;
安装
npm i react-scoped-styles
用法
该模块假定组件文件及其样式在同一目录中。这是手写
【文件预览】:
react-scoped-styles-master
----src()
--------script-loader.ts(1KB)
--------options.ts(125B)
--------index.ts(40B)
--------lib()
--------style-loader.ts(766B)
----.npmignore(24B)
----tsconfig.json(5KB)
----README.md(5KB)
----.gitignore(42B)
----package-lock.json(2KB)
----package.json(634B)