mirror of
https://github.com/ElemeFE/element.git
synced 2025-12-16 11:44:01 +08:00
Notification: supports VNode, #1885
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import Vue from 'vue';
|
||||
import { PopupManager } from 'element-ui/src/utils/popup';
|
||||
import { isVNode } from 'element-ui/src/utils/vdom';
|
||||
let NotificationConstructor = Vue.extend(require('./main.vue'));
|
||||
|
||||
let instance;
|
||||
@@ -19,6 +20,11 @@ var Notification = function(options) {
|
||||
instance = new NotificationConstructor({
|
||||
data: options
|
||||
});
|
||||
|
||||
if (isVNode(options.message)) {
|
||||
instance.$slots.default = [options.message];
|
||||
options.message = '';
|
||||
}
|
||||
instance.id = id;
|
||||
instance.vm = instance.$mount();
|
||||
document.body.appendChild(instance.vm.$el);
|
||||
@@ -39,7 +45,7 @@ var Notification = function(options) {
|
||||
|
||||
['success', 'warning', 'info', 'error'].forEach(type => {
|
||||
Notification[type] = options => {
|
||||
if (typeof options === 'string') {
|
||||
if (typeof options === 'string' || isVNode(options)) {
|
||||
options = {
|
||||
message: options
|
||||
};
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
v-if="type || iconClass">
|
||||
</i>
|
||||
<div class="el-notification__group" :class="{ 'is-with-icon': typeClass || iconClass }">
|
||||
<span>{{ title }}</span>
|
||||
<p>{{ message }}</p>
|
||||
<h2 class="el-notification__title" v-text="title"></h2>
|
||||
<div class="el-notification__content"><slot>{{ message }}</slot></div>
|
||||
<div class="el-notification__closeBtn el-icon-close" @click="close"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user