mirror of https://github.com/ElemeFE/element
Message: fix message[type] (#21088)
parent
09e789bad2
commit
1ef72a3283
|
@ -2,6 +2,7 @@ import Vue from 'vue';
|
|||
import Main from './main.vue';
|
||||
import { PopupManager } from 'element-ui/src/utils/popup';
|
||||
import { isVNode } from 'element-ui/src/utils/vdom';
|
||||
import { isObject } from 'element-ui/src/utils/types';
|
||||
let MessageConstructor = Vue.extend(Main);
|
||||
|
||||
let instance;
|
||||
|
@ -44,14 +45,17 @@ const Message = function(options) {
|
|||
};
|
||||
|
||||
['success', 'warning', 'info', 'error'].forEach(type => {
|
||||
Message[type] = options => {
|
||||
if (typeof options === 'string') {
|
||||
options = {
|
||||
message: options
|
||||
};
|
||||
Message[type] = (options) => {
|
||||
if (isObject(options) && !isVNode(options)) {
|
||||
return Message({
|
||||
...options,
|
||||
type
|
||||
});
|
||||
}
|
||||
options.type = type;
|
||||
return Message(options);
|
||||
return Message({
|
||||
type,
|
||||
message: options
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue