2017-01-27 17:12:25 +08:00
|
|
|
---
|
|
|
|
order: 5
|
|
|
|
title:
|
|
|
|
zh-CN: 位置
|
|
|
|
en-US: Placement
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
可以设置通知从右上角、右下角、左下角、左上角弹出。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
2019-04-19 22:36:29 +08:00
|
|
|
A notification box can appear from the `topRight`, `bottomRight`, `bottomLeft` or `topLeft` of the viewport.
|
2017-01-27 17:12:25 +08:00
|
|
|
|
2017-02-13 10:55:53 +08:00
|
|
|
````jsx
|
2017-01-27 17:12:25 +08:00
|
|
|
import { Button, Select, notification } from 'antd';
|
|
|
|
|
|
|
|
const { Option } = Select;
|
2017-02-13 10:55:53 +08:00
|
|
|
const options = ['topLeft', 'topRight', 'bottomLeft', 'bottomRight'];
|
2017-01-27 17:12:25 +08:00
|
|
|
const openNotification = () => {
|
|
|
|
notification.open({
|
|
|
|
message: 'Notification Title',
|
|
|
|
description: 'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
ReactDOM.render(
|
|
|
|
<div>
|
|
|
|
<Select
|
|
|
|
defaultValue="topRight"
|
|
|
|
style={{ width: 120, marginRight: 10 }}
|
2017-02-13 10:55:53 +08:00
|
|
|
onChange={(val) => {
|
2017-01-27 17:12:25 +08:00
|
|
|
notification.config({
|
|
|
|
placement: val,
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{options.map(val => <Option key={val} value={val}>{val}</Option>)}
|
|
|
|
</Select>
|
|
|
|
<Button
|
|
|
|
type="primary"
|
|
|
|
onClick={openNotification}
|
|
|
|
>
|
|
|
|
Open the notification box
|
|
|
|
</Button>
|
2018-06-27 15:55:04 +08:00
|
|
|
</div>,
|
2018-11-28 15:00:03 +08:00
|
|
|
mountNode
|
|
|
|
);
|
2017-01-27 17:12:25 +08:00
|
|
|
````
|