是否有任何方法可以在header
中存储section.type
不同的标题,如<p> {section.title1} </p>
或<p> {section.title2} </p>
?
return (
<Collapse
onToggle={onHandleClick}
header={
<p> {section.title1} </p>
}
</Collapse>
);
是的,你可以这样做:
header={
<p> {section.type ? section.title1 : section.title2} </p>
}
你可以做一个条件渲染:
return (
<Collapse
onToggle={onHandleClick}
header={
section.type ? <p>{section.title1}</p> : <p>{section.title2}</p>
}
</Collapse>
)