如何在样式组件中导入 antd.css?而不是 App.css
@import '~antd/dist/antd.css';
整个目的是,我希望 styled-components 中的 GlobalStyles 默认具有所有 Ant Design 样式。
当我使用 AntD 中的元素时,它将包含所有默认类。
最佳答案
NOTE: At this time we recommend not using @import inside of
createGlobalStyle
. We're working on better behavior for this functionality but it just doesn't really work at the moment and it's better if you just embed these imports in your HTML index file, etc.
虽然你可以尝试:
import { createGlobalStyle, css } from 'styled-components';
const antdCss = css`
${import('antd/dist/antd.css')}
`;
const GlobalStyle = createGlobalStyle`
${antdCss}
`;
export default GlobalStyle;
关于reactjs - 如何在 styled-components 的 GlobalStyles 中引入 Ant Design 的 css 样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59848920/