【问题标题】:How do I import Ant Design React UI library and css?如何导入 Ant Design React UI 库和 css?
【发布时间】:2019-10-23 07:28:44
【问题描述】:

我对 React 中的 UI 库和 css 非常陌生。我正在使用 Ant Design 的数据选择器:https://ant.design/docs/react/introduce。

他们提供 CodePen 示例,在 css 选项卡中您可以看到:

@import 'antd/dist/antd.css';

但是,当我将它添加到我的 css 样式表中时,我使用 `import './Component.css'; 将其导入到组件中;我在组件文件夹中收到错误“找不到模块:无法解析'./antd/dist/antd.css'”。

我已经安装了 npm 包,但无法让 css 工作。

我做错了什么?

非常感谢。

【问题讨论】:

  • 你能分享你的 package.json 吗?

标签: css reactjs


【解决方案1】:

确保antd 安装正确,并且在您的package.json 中可见,它应该在那里

"antd": "3.19.2" 假设你跑了npm i antd

以及使用

将其导入您的组件中

import { DatePicker } from 'antd';

然后在你的组件中手动导入样式

import 'antd/dist/antd.css';

【讨论】:

  • @That'sEnam 你能解释更多吗?你看到了什么错误?
猜你喜欢
  • 2020-05-07
  • 2020-03-09
  • 2019-10-22
  • 2020-12-01
  • 2022-12-14
  • 2021-09-30
  • 2021-05-17
  • 1970-01-01
  • 2020-03-11
相关资源
最近更新 更多