我正在尝试将 react-bootstrap 与 Bootstrap 5 一起使用。我想在我的一个页面中使用 Accordion。为此,我只是从这个页面复制了结构-> https://react-bootstrap.netlify.app/components/accordion/。但是当我打开页面时,浏览器显示此错误-
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of `Questions`.
这是我使用此组件的代码
import Accordion from 'react-bootstrap/Accordion';
const Questions = () => (
<Accordion defaultActiveKey="0" flush>
<Accordion.Item eventKey="0">
<Accordion.Header>Question #1</Accordion.Header>
<Accordion.Body>
Answer to the Question #1
</Accordion.Body>
</Accordion.Item>
<Accordion.Item eventKey="1">
<Accordion.Header>Question #2</Accordion.Header>
<Accordion.Body>
Answer to the Question #2
</Accordion.Body>
</Accordion.Item>
</Accordion>
);
export default Questions;
其他详情:
- “引导程序”:“^5.0.2”
- “react”:“^17.0.2”
- “react引导”:“^1.6.1”
导入/导出组件时我错过了什么吗?TIA。