我正在尝试使用 css 模块为一个元素使用多个类。我该怎么做呢?
function Footer( props) {
const { route } = props;
return (
<div className={styles.footer}>
<div className={styles.description, styles.yellow}>
<p>this site was created by me</p>
</div>
<div className={styles.description}>
<p>copyright nz</p>
</div>
</div>
);
}
您可以使用 css 模块添加多个类,如下所示:
className={`${styles.description} ${styles.yellow}`}
e.g.
function Footer( props) {
return (
<div className={styles.footer}>
<div className={`${styles.description} ${styles.yellow}`}>
<p>this site was created by me</p>
</div>
</div>
);
}
Using 反应CSS模块 https://github.com/gajus/react-css-modules您可以使用普通的类名语法:
<div styleName='description yellow'>
并且你指定allowMultiple: true
对于多个班级
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)