Browse Source

Merge pull request #93 from ant-design/message-global-config

support config message top globally
pull/114/head
偏右 9 years ago
parent
commit
95dde2aeea
  1. 1
      components/message/demo/success.md
  2. 10
      components/message/index.jsx
  3. 15
      components/message/index.md

1
components/message/demo/success.md

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

10
components/message/index.jsx

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

15
components/message/index.md

@ -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…
Cancel
Save