【发布时间】:2021-06-12 13:04:06
【问题描述】:
我在我的 create-react-app 项目中按需导入 antd 组件,例如 Collapse、Tabs、Select 等,它们会进行一些解构 如:
import { Tabs } from "antd/lib/tabs";
import 'antd/lib/tabs/style/css';
import { Collapse } from "antd/lib/collapse";
import 'antd/lib/collapse/style/css';
import { Select } from "antd/lib/select";
import 'antd/lib/select/style/css';
const { Panel } = Collapse;
const { TabPane } = Tabs;
const { Option } = Select;
我收到错误TypeError: Cannot destructure property 'Panel' of 'antd_lib_collapse__WEBPACK_IMPORTED_MODULE_3__.Collapse' as it is undefined.
我不想使用import { Collapse, Select } from "antd";,因为它带来了大量的javascript。我做错了什么?
【问题讨论】:
标签: reactjs create-react-app antd destructuring