【发布时间】:2020-01-23 20:30:22
【问题描述】:
实际上,我继承了一个 ReactJS Web 应用程序,它由 CRA 和 Ant-Design 初始化。我刚刚使用 Material-UI,没有使用 And Design 的经验。
Material-UI 处理样式的方式很棒,但 AntD 使用 less 处理 CSS。我很难像古人一样工作。
我搜索了很多,但没有找到在 Ant Design 项目中使用 JSS[CSS in JS] 的方法。
我的意思如下:
import { AntDCompo } from 'antd';
import { Styled , injectStyled } from 'react-jss';
const MyCompo = ({ classes }) => (
<AntDCompo className={classes.container} />
);
const styles = Styled({
container: {
color: '#f00',
},
});
export default injectStyled(styles)(MyCompo);
但是在 Ant Design 文档中只是像古老的东西一样声明:
import { AntDCompo } from 'antd';
import styles from 'myCompoStyles.less';
const MyCompo = () => (
<AntDCompo className={styles.container} />
);
我该怎么做?或者有什么方法可以将 JSS 用于 AndD 组件?
【问题讨论】:
标签: css reactjs antd jss css-in-js