Skip to content

Commit 724777b

Browse files
committed
Message: fix message[type]
1 parent 1b7ff34 commit 724777b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

packages/message/src/main.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Vue from 'vue';
22
import Main from './main.vue';
33
import { PopupManager } from 'element-ui/src/utils/popup';
44
import { isVNode } from 'element-ui/src/utils/vdom';
5+
import { isObject } from 'element-ui/src/utils/types';
56
let MessageConstructor = Vue.extend(Main);
67

78
let instance;
@@ -44,14 +45,17 @@ const Message = function(options) {
4445
};
4546

4647
['success', 'warning', 'info', 'error'].forEach(type => {
47-
Message[type] = options => {
48-
if (typeof options === 'string') {
49-
options = {
50-
message: options
51-
};
48+
Message[type] = (options) => {
49+
if (isObject(options) && !isVNode(options)) {
50+
return Message({
51+
...options,
52+
type
53+
});
5254
}
53-
options.type = type;
54-
return Message(options);
55+
return Message({
56+
type,
57+
message: options
58+
});
5559
};
5660
});
5761

0 commit comments

Comments
 (0)