mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-03 00:09:39 +08:00
7fd093bd0a
* docs: add general components TS demo * docs: add layout components TS demo * docs: add navigation components TS demo * docs: add data entry components TS demo * chore(deps): add types for qs * docs: add data display TS demo * docs: add feedback components TS demo * docs: add other components TS demo * chore(deps): add types * docs: unified demo code style * docs: fix lint error * docs: add demo TS type * docs: fix demo TS type * test: update snapshot * docs: fix TS demo * feat: update Rate character type * docs: fix lint error * feat: update Rate character type * feat: update Rate character type
131 lines
3.2 KiB
Markdown
Executable File
131 lines
3.2 KiB
Markdown
Executable File
---
|
|
order: 2
|
|
title:
|
|
zh-CN: 位置
|
|
en-US: Placement
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
位置有十二个方向。如需箭头指向目标元素中心,可以设置 `arrowPointAtCenter`。
|
|
|
|
## en-US
|
|
|
|
There are 12 `placement` options available. Use `arrowPointAtCenter` if you want the arrow to point at the center of target.
|
|
|
|
```tsx
|
|
import React from 'react';
|
|
import { Popconfirm, message, Button } from 'antd';
|
|
|
|
const text = 'Are you sure to delete this task?';
|
|
|
|
const confirm = () => {
|
|
message.info('Clicked on Yes.');
|
|
};
|
|
|
|
const App: React.FC = () => (
|
|
<div className="demo">
|
|
<div style={{ marginLeft: 70, whiteSpace: 'nowrap' }}>
|
|
<Popconfirm placement="topLeft" title={text} onConfirm={confirm} okText="Yes" cancelText="No">
|
|
<Button>TL</Button>
|
|
</Popconfirm>
|
|
<Popconfirm placement="top" title={text} onConfirm={confirm} okText="Yes" cancelText="No">
|
|
<Button>Top</Button>
|
|
</Popconfirm>
|
|
<Popconfirm
|
|
placement="topRight"
|
|
title={text}
|
|
onConfirm={confirm}
|
|
okText="Yes"
|
|
cancelText="No"
|
|
>
|
|
<Button>TR</Button>
|
|
</Popconfirm>
|
|
</div>
|
|
<div style={{ width: 70, float: 'left' }}>
|
|
<Popconfirm placement="leftTop" title={text} onConfirm={confirm} okText="Yes" cancelText="No">
|
|
<Button>LT</Button>
|
|
</Popconfirm>
|
|
<Popconfirm placement="left" title={text} onConfirm={confirm} okText="Yes" cancelText="No">
|
|
<Button>Left</Button>
|
|
</Popconfirm>
|
|
<Popconfirm
|
|
placement="leftBottom"
|
|
title={text}
|
|
onConfirm={confirm}
|
|
okText="Yes"
|
|
cancelText="No"
|
|
>
|
|
<Button>LB</Button>
|
|
</Popconfirm>
|
|
</div>
|
|
<div style={{ width: 70, marginLeft: 304 }}>
|
|
<Popconfirm
|
|
placement="rightTop"
|
|
title={text}
|
|
onConfirm={confirm}
|
|
okText="Yes"
|
|
cancelText="No"
|
|
>
|
|
<Button>RT</Button>
|
|
</Popconfirm>
|
|
<Popconfirm placement="right" title={text} onConfirm={confirm} okText="Yes" cancelText="No">
|
|
<Button>Right</Button>
|
|
</Popconfirm>
|
|
<Popconfirm
|
|
placement="rightBottom"
|
|
title={text}
|
|
onConfirm={confirm}
|
|
okText="Yes"
|
|
cancelText="No"
|
|
>
|
|
<Button>RB</Button>
|
|
</Popconfirm>
|
|
</div>
|
|
<div style={{ marginLeft: 70, clear: 'both', whiteSpace: 'nowrap' }}>
|
|
<Popconfirm
|
|
placement="bottomLeft"
|
|
title={text}
|
|
onConfirm={confirm}
|
|
okText="Yes"
|
|
cancelText="No"
|
|
>
|
|
<Button>BL</Button>
|
|
</Popconfirm>
|
|
<Popconfirm placement="bottom" title={text} onConfirm={confirm} okText="Yes" cancelText="No">
|
|
<Button>Bottom</Button>
|
|
</Popconfirm>
|
|
<Popconfirm
|
|
placement="bottomRight"
|
|
title={text}
|
|
onConfirm={confirm}
|
|
okText="Yes"
|
|
cancelText="No"
|
|
>
|
|
<Button>BR</Button>
|
|
</Popconfirm>
|
|
</div>
|
|
</div>
|
|
);
|
|
|
|
export default App;
|
|
```
|
|
|
|
<style>
|
|
.code-box-demo .demo {
|
|
overflow: auto;
|
|
}
|
|
.code-box-demo .ant-popover-wrap > a {
|
|
margin-right: 8px;
|
|
}
|
|
.code-box-demo .ant-btn {
|
|
margin-right: 8px;
|
|
margin-bottom: 8px;
|
|
}
|
|
#components-popconfirm-demo-placement .ant-btn {
|
|
width: 70px;
|
|
text-align: center;
|
|
padding: 0;
|
|
}
|
|
</style>
|