Skip to content

Commit

Permalink
Message: fix message[type] (#21088)
Browse files Browse the repository at this point in the history
  • Loading branch information
cs1707 authored Jul 23, 2021
1 parent 09e789b commit 1ef72a3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/message/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
});
};
});

Expand Down

0 comments on commit 1ef72a3

Please sign in to comment.