简体   繁体   English

Ant 设计折叠不适用于 Map

[英]Ant design Collapse is not working with Map

I'm using collapse using Ant-Design put inside the Collapse tag if I put Map for panel, It's not working can someone suggest me the solution.如果我将 Map 用于面板,我将使用 Ant-Design 使用折叠标签内的折叠,有人可以建议我解决方案。 Without Map It work.没有 Map 它可以工作。 But using Map it's not.但是使用 Map 不是。

Here is the Code:这是代码:

<Collapse
              defaultActiveKey={["1"]}
              accordion
              expandIcon={(props) => customExpandIcon(props)}
              ghost
            >
              {JSON.map((assesment, index) => (
                  
              <div>
              <Panel index header="This is panel header 1" key="1">
                <p>Header1</p>
              </Panel>
              </div>
                ))}
            </Collapse>

There seems to be a few problems I would like to point out that should be corrected.似乎有一些问题我想指出应该纠正的。

  1. It is not JSON.map but some list of objects (maybe assesments.map).它不是 JSON.map 而是一些对象列表(可能是 assesments.map)。
  2. I think Panel has to be a direct decendent of Collapse so it should not be in a div tag.我认为 Panel 必须是 Collapse 的直接后代,所以它不应该在 div 标签中。
  3. Key property should be index so that not all panels have key 1键属性应该是索引,以便并非所有面板都有键 1

Here you have a example using map https://codesandbox.io/s/mystifying-microservice-tuef7?file=/index.js这里有一个使用 map https://codesandbox.io/s/mystifying-microservice-tuef7?file=/index.js的示例

Please ask any questions if this did not answer your question.如果这没有回答您的问题,请提出任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM