React CSS Module
在React中使用Css module很简单
比如同一目录下有index.js 和 index.less
在index.js中要使用index.less的样式
需要这样引入
import styles from './index.less'
注意路径写全,不能省略./
然后使用className={styles['.btn']}就行了,可以避免局部样式影响全局样式
掌控自己,掌控命运
在React中使用Css module很简单
比如同一目录下有index.js 和 index.less
在index.js中要使用index.less的样式
需要这样引入
import styles from './index.less'
注意路径写全,不能省略./
然后使用className={styles['.btn']}就行了,可以避免局部样式影响全局样式