2020-11-30 15:20:42 +08:00
|
|
|
---
|
|
|
|
order: 7
|
|
|
|
title:
|
|
|
|
zh-CN: 可折叠触发区域
|
|
|
|
en-US: Collapsible
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
通过 `collapsible` 属性,可以设置面板的可折叠触发区域。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Specify the trigger area of collapsible by `collapsible`.
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2020-11-30 15:20:42 +08:00
|
|
|
import { Collapse, Space } from 'antd';
|
2022-05-21 22:14:15 +08:00
|
|
|
import React from 'react';
|
2020-11-30 15:20:42 +08:00
|
|
|
|
|
|
|
const { Panel } = Collapse;
|
|
|
|
|
|
|
|
const text = `
|
|
|
|
A dog is a type of domesticated animal.
|
|
|
|
Known for its loyalty and faithfulness,
|
|
|
|
it can be found as a welcome guest in many households across the world.
|
|
|
|
`;
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => (
|
2020-11-30 15:20:42 +08:00
|
|
|
<Space direction="vertical">
|
|
|
|
<Collapse collapsible="header" defaultActiveKey={['1']}>
|
|
|
|
<Panel header="This panel can only be collapsed by clicking text" key="1">
|
|
|
|
<p>{text}</p>
|
|
|
|
</Panel>
|
|
|
|
</Collapse>
|
|
|
|
<Collapse collapsible="disabled">
|
|
|
|
<Panel header="This panel can't be collapsed" key="1">
|
|
|
|
<p>{text}</p>
|
|
|
|
</Panel>
|
|
|
|
</Collapse>
|
2022-04-03 23:27:45 +08:00
|
|
|
</Space>
|
2020-11-30 15:20:42 +08:00
|
|
|
);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
export default App;
|
2020-11-30 15:20:42 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
<style>
|
|
|
|
[data-theme="compact"] p, p {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
#components-collapse-demo-collapsible .ant-space {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
</style>
|