support config message top globally

This commit is contained in:
afc163 2015-07-30 11:47:46 +08:00
parent e792a7d10b
commit b607ab32cf
3 changed files with 25 additions and 1 deletions

View File

@ -8,6 +8,7 @@
````jsx
var message = antd.message;
var success = function() {
message.success('这是一条成功的提示');
};

View File

@ -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;
}
}
};

View File

@ -25,3 +25,18 @@
|------------|----------------|----------------------------|--------------|
| content | 提示内容 | React.Element or String | 无 |
| duration | 自动关闭的延时 | number | 1.5 |
还提供了一个全局配置方法:
- `message.config(options)`
```js
message.config({
top: 100
});
```
| 参数 | 说明 | 类型 | 默认值 |
|------------|--------------------|----------------------------|--------------|
| top | 消息距离顶部的位置 | Number | 24px |