mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 19:19:26 +08:00
support config message top globally
This commit is contained in:
parent
e792a7d10b
commit
b607ab32cf
@ -8,6 +8,7 @@
|
||||
|
||||
````jsx
|
||||
var message = antd.message;
|
||||
|
||||
var success = function() {
|
||||
message.success('这是一条成功的提示');
|
||||
};
|
||||
|
@ -2,12 +2,15 @@ import React from 'react';
|
||||
import Notification from 'rc-notification';
|
||||
|
||||
let defaultDuration = 1.5;
|
||||
let top;
|
||||
|
||||
function getMessageInstance() {
|
||||
return Notification.newInstance({
|
||||
prefixCls: 'ant-message',
|
||||
transitionName: 'move-up',
|
||||
style: {} // 覆盖原来的样式
|
||||
style: {
|
||||
top: top
|
||||
} // 覆盖原来的样式
|
||||
});
|
||||
}
|
||||
|
||||
@ -37,5 +40,10 @@ export default {
|
||||
},
|
||||
error(content, duration) {
|
||||
notice(content, duration, 'error');
|
||||
},
|
||||
config(options) {
|
||||
if (options.top) {
|
||||
top = options.top;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -25,3 +25,18 @@
|
||||
|------------|----------------|----------------------------|--------------|
|
||||
| content | 提示内容 | React.Element or String | 无 |
|
||||
| duration | 自动关闭的延时 | number | 1.5 |
|
||||
|
||||
|
||||
还提供了一个全局配置方法:
|
||||
|
||||
- `message.config(options)`
|
||||
|
||||
```js
|
||||
message.config({
|
||||
top: 100
|
||||
});
|
||||
```
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
|------------|--------------------|----------------------------|--------------|
|
||||
| top | 消息距离顶部的位置 | Number | 24px |
|
||||
|
Loading…
Reference in New Issue
Block a user