TypeError: 无法读取未定义的属性(读取’item’)

huangapple go评论81阅读模式
英文:

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 &#39;react&#39;
import { Accordion} from &#39;react-bootstrap/Accordion&#39;;
import { ToastContainer } from &#39;react-toastify&#39;;
const myaccordion = () =&gt; {
  return (
    &lt;&gt;
    &lt;Accordion defulatActivateKey=&quot;0&quot; className=&#39;mt-5 p-3&#39;&gt;
        &lt;Accordion.item eventKey=&quot;0&quot; className=&quot;item&quot; &gt;
            &lt;Accordion.header&gt;Accordion Header #1&lt;/Accordion.header&gt;
            &lt;Accordion.body&gt;
            Lorem Ipsum is simply dummy text of the printing and typesetting industry.
            &lt;/Accordion.body&gt;
        &lt;/Accordion.item&gt;
        &lt;Accordion.item eventKey=&quot;2&quot; className=&quot;item&quot;&gt;
            &lt;Accordion.header&gt;Accordion Header #1&lt;/Accordion.header&gt;
            &lt;Accordion.body&gt;
            Lorem Ipsum is simply dummy text of the printing and typesetting industry.
            &lt;/Accordion.body&gt;
        &lt;/Accordion.item&gt;
        &lt;Accordion.item eventKey=&quot;3&quot; className=&quot;item&quot;&gt;
            &lt;Accordion.header&gt;Accordion Header #1&lt;/Accordion.header&gt;
            &lt;Accordion.body&gt;
            Lorem Ipsum is simply dummy text of the printing and typesetting industry.
            &lt;/Accordion.body&gt;
        &lt;/Accordion.item&gt;
    &lt;/Accordion&gt;
    &lt;ToastContainer /&gt;
    &lt;/&gt;
  )
}

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 &#39;react-bootstrap/Accordion&#39;;

Wrong ❌:

import { Accordion } from &#39;react-bootstrap/Accordion&#39;;

huangapple
  • 本文由 发表于 2023年6月6日 01:26:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76408735.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定