mirror of https://github.com/ElemeFE/element
parent
b4e4efd872
commit
9e32cccc73
|
@ -191,6 +191,7 @@ import { Message } from 'element-ui';
|
|||
```
|
||||
|
||||
In this case you should call `Message(options)`. We have also registered methods for different types, e.g. `Message.success(options)`.
|
||||
You can call `Message.closeAll()` to manually close all the instances.
|
||||
|
||||
### Options
|
||||
| Attribute | Description | Type | Accepted Values | Default |
|
||||
|
|
|
@ -191,6 +191,7 @@ import { Message } from 'element-ui';
|
|||
```
|
||||
|
||||
此时调用方法为 `Message(options)`。我们也为每个 type 定义了各自的方法,如 `Message.success(options)`。
|
||||
并且可以调用 `Message.closeAll()` 手动关闭所有实例。
|
||||
|
||||
### Options
|
||||
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
||||
|
|
|
@ -58,4 +58,10 @@ Message.close = function(id, userOnClose) {
|
|||
}
|
||||
};
|
||||
|
||||
Message.closeAll = function() {
|
||||
for (let i = instances.length - 1; i >= 0; i--) {
|
||||
instances[i].close();
|
||||
}
|
||||
};
|
||||
|
||||
export default Message;
|
||||
|
|
|
@ -41,6 +41,24 @@ describe('Message', () => {
|
|||
}, 500);
|
||||
});
|
||||
|
||||
it('close all', done => {
|
||||
Message({
|
||||
message: '夏天',
|
||||
duration: 0
|
||||
});
|
||||
Message({
|
||||
message: '淑女',
|
||||
duration: 0
|
||||
});
|
||||
setTimeout(() => {
|
||||
Message.closeAll();
|
||||
setTimeout(() => {
|
||||
expect(document.querySelector('.el-message')).to.not.exist;
|
||||
done();
|
||||
}, 500);
|
||||
}, 500);
|
||||
});
|
||||
|
||||
it('create', () => {
|
||||
Message('娜梅莉亚');
|
||||
expect(document.querySelector('.el-message')).to.exist;
|
||||
|
|
Loading…
Reference in New Issue