|
5 | 5 | this.$message('This is a message.');
|
6 | 6 | },
|
7 | 7 |
|
| 8 | + openVn() { |
| 9 | + const h = this.$createElement; |
| 10 | + this.$message({ |
| 11 | + message: h('p', null, [ |
| 12 | + h('span', null, 'Message can be '), |
| 13 | + h('i', { style: 'color: teal' }, 'VNode') |
| 14 | + ]) |
| 15 | + }); |
| 16 | + }, |
| 17 | + |
8 | 18 | open2() {
|
9 | 19 | this.$message({
|
10 | 20 | message: 'Congrats, this is a success message.',
|
@@ -65,18 +75,29 @@ Used to show feedback after an activity. The difference with Notification is tha
|
65 | 75 |
|
66 | 76 | Displays at the top, and disappears after 3 seconds.
|
67 | 77 |
|
68 |
| -:::demo The setup of Message is very similar to notification, so parts of the options won't be explained in detail here. You can check the options table below combined with notification doc to understand it. Element has registered a `$message` method for invoking. Message can take a string as parameter, and it will be shown as the main body. |
| 78 | +:::demo The setup of Message is very similar to notification, so parts of the options won't be explained in detail here. You can check the options table below combined with notification doc to understand it. Element has registered a `$message` method for invoking. Message can take a string or VNode as parameter, and it will be shown as the main body. |
69 | 79 |
|
70 | 80 | ```html
|
71 | 81 | <template>
|
72 | 82 | <el-button :plain="true" @click="open">Show message</el-button>
|
| 83 | + <el-button :plain="true" @click="openVn">VNode</el-button> |
73 | 84 | </template>
|
74 | 85 |
|
75 | 86 | <script>
|
76 | 87 | export default {
|
77 | 88 | methods: {
|
78 | 89 | open() {
|
79 | 90 | this.$message('This is a message.');
|
| 91 | + }, |
| 92 | + |
| 93 | + openVn() { |
| 94 | + const h = this.$createElement; |
| 95 | + this.$message({ |
| 96 | + message: h('p', null, [ |
| 97 | + h('span', null, 'Message can be '), |
| 98 | + h('i', { style: 'color: teal' }, 'VNode') |
| 99 | + ]) |
| 100 | + }); |
80 | 101 | }
|
81 | 102 | }
|
82 | 103 | }
|
@@ -196,7 +217,7 @@ You can call `Message.closeAll()` to manually close all the instances.
|
196 | 217 | ### Options
|
197 | 218 | | Attribute | Description | Type | Accepted Values | Default |
|
198 | 219 | |---------- |-------------- |---------- |-------------------------------- |-------- |
|
199 |
| -| message | message text | string | — | — | |
| 220 | +| message | message text | string / VNode | — | — | |
200 | 221 | | type | message type | string | success/warning/info/error | info |
|
201 | 222 | | iconClass | custom icon's class, overrides `type` | string | — | — |
|
202 | 223 | | customClass | custom class name for Message | string | — | — |
|
|
0 commit comments