问题描述 投票:0回答:0
@dbs说,使用JSX,您应该创建和返回整个元素,因此您正在寻找类似的东西:

cpu.map((item, index) => ( <div key={item.id /* or index if your items don't have ids */} class="usage-row"> {Array.from({ length: 8 }, (_, j) => ( <div key={j} class="cpu"> <i class={`bi bi-circle-fill ${item.description} led`}></i> CPU {item.realname} </div> ))} </div> )
,不应该由呼叫返回的每个元素都有一个唯一的propert react将在内部使用。
    

reactjs jsx
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.