使用create-react-app創(chuàng)建的項目,默認情況下就支持css-module
1、樣式文件必須以[name].module.css或[name].module.scss的形式命名
2类早、以變量的形式導入樣式文件,比如 import styles from './style.module.css';
3送巡、className以變量引用的方式添加柴信,比如 className={ styles.title }
import React, { Component } from 'react'
import styles from './Style5.module.scss'
export default class Style5 extends Component {
render() {
return (
<div>
<div className={styles.title}>我是標題</div>
</div>
)
}
}