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 Main from './main.vue';
|
||||||
import { PopupManager } from 'element-ui/src/utils/popup';
|
import { PopupManager } from 'element-ui/src/utils/popup';
|
||||||
import { isVNode } from 'element-ui/src/utils/vdom';
|
import { isVNode } from 'element-ui/src/utils/vdom';
|
||||||
|
import { isObject } from 'element-ui/src/utils/types';
|
||||||
let MessageConstructor = Vue.extend(Main);
|
let MessageConstructor = Vue.extend(Main);
|
||||||
|
|
||||||
let instance;
|
let instance;
|
||||||
|
@ -44,14 +45,17 @@ const Message = function(options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
['success', 'warning', 'info', 'error'].forEach(type => {
|
['success', 'warning', 'info', 'error'].forEach(type => {
|
||||||
Message[type] = options => {
|
Message[type] = (options) => {
|
||||||
if (typeof options === 'string') {
|
if (isObject(options) && !isVNode(options)) {
|
||||||
options = {
|
return Message({
|
||||||
message: options
|
...options,
|
||||||
};
|
type
|
||||||
|
});
|
||||||
}
|
}
|
||||||
options.type = type;
|
return Message({
|
||||||
return Message(options);
|
type,
|
||||||
|
message: options
|
||||||
|
});
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue