首页 > 解决方案 > 在 React 中链接样式的一些解决方案?

问题描述

在使用css-modules做出反应时,我将类分配给这样的组件

import styles from './styles.module.css'

const SomeComponent = () => (
  <ChildComponent className={styles.SomeClass + ' ' + styles.AnotherClass} />
)

或者我可以这样分配

<ChildComponent className={`${styles.SomeClass} ${styles.AnotherClass}` />

您能否建议如何转换样式变量的方式,我们可以像这样分配类

<ChildComponent className={styles.SomeClass.AnotherClass.OneMoreClass />

当然,我们可以使用一两个或尽可能多的类

标签: javascriptreactjsreact-css-modules

解决方案


推荐阅读