Message: fix message[type] (#21088)

pull/21185/head
好多大米 2021-07-23 17:22:18 +08:00 committed by GitHub
parent 09e789bad2
commit 1ef72a3283
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 7 deletions

View File

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