英文:
TypeError: Cannot read properties of undefined (reading 'item')
问题
以下是代码的翻译部分:
这是我在尝试运行以下代码时不断遇到的错误。
import React from 'react'
import { Accordion } from 'react-bootstrap/Accordion';
import { ToastContainer } from 'react-toastify';
const myaccordion = () => {
return (
<>
<Accordion defulatActivateKey="0" className='mt-5 p-3'>
<Accordion.item eventKey="0" className="item" >
<Accordion.header>Accordion Header #1</Accordion.header>
<Accordion.body>
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</Accordion.body>
</Accordion.item>
<Accordion.item eventKey="2" className="item">
<Accordion.header>Accordion Header #1</Accordion.header>
<Accordion.body>
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</Accordion.body>
</Accordion.item>
<Accordion.item eventKey="3" className="item">
<Accordion.header>Accordion Header #1</Accordion.header>
<Accordion.body>
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</Accordion.body>
</Accordion.item>
</Accordion>
<ToastContainer />
</>
)
}
export default myaccordion
有人能告诉我如何替代使用accordion-bootstrap吗?
英文:
This is the error I keep getting when I am trying to run the code given below.
import React from 'react'
import { Accordion} from 'react-bootstrap/Accordion';
import { ToastContainer } from 'react-toastify';
const myaccordion = () => {
return (
<>
<Accordion defulatActivateKey="0" className='mt-5 p-3'>
<Accordion.item eventKey="0" className="item" >
<Accordion.header>Accordion Header #1</Accordion.header>
<Accordion.body>
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</Accordion.body>
</Accordion.item>
<Accordion.item eventKey="2" className="item">
<Accordion.header>Accordion Header #1</Accordion.header>
<Accordion.body>
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</Accordion.body>
</Accordion.item>
<Accordion.item eventKey="3" className="item">
<Accordion.header>Accordion Header #1</Accordion.header>
<Accordion.body>
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</Accordion.body>
</Accordion.item>
</Accordion>
<ToastContainer />
</>
)
}
export default myaccordion
Can someone tell me an alternative to how to use accordion-bootstrap.
答案1
得分: 2
Correct ✅:
import Accordion from 'react-bootstrap/Accordion';
英文:
Correct ✅:
import Accordion from 'react-bootstrap/Accordion';
Wrong ❌:
import { Accordion } from 'react-bootstrap/Accordion';
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论