我想将按钮置于折叠状态,我正在使用antd折叠状态,当我尝试出现错误时,这可能吗?该新按钮不应打开或关闭折叠,我想给她其他功能,如何将按钮放入折叠?
const { Collapse, Button } = antd;
const { Panel } = Collapse;
function callback(key) {
console.log(key);
}
const text = ` hi `;
ReactDOM.render(
<Collapse
defaultActiveKey={['1']} onChange={callback}>
<Panel header="This is panel header 1" key="1"
<Button type="link">My button</Button> >
<p>{text}</p>
</Panel>
</Collapse>,
mountNode,
);
错误是:
Identifier expected.
Expected corresponding JSX closing tag for 'Collapse'.
如果要在面板内放置按钮,则按钮代码应在面板内,而不是其标签内。而不是:
<Panel header="This is panel header 1" key="1"
<Button type="link">My button</Button> >
应该是
<Panel header="This is panel header 1" key="1">
<Button type="link">My button</Button>
</Panel>