message: optimize code (#14029)

pull/14278/head
vok123 2019-01-30 19:25:26 +08:00 committed by hetech
parent 516f76e6cf
commit 4eefc2a552
1 changed files with 2 additions and 4 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<transition name="el-message-fade"> <transition name="el-message-fade" @after-leave="handleAfterLeave">
<div <div
:class="[ :class="[
'el-message', 'el-message',
@ -61,14 +61,12 @@
closed(newVal) { closed(newVal) {
if (newVal) { if (newVal) {
this.visible = false; this.visible = false;
this.$el.addEventListener('transitionend', this.destroyElement);
} }
} }
}, },
methods: { methods: {
destroyElement() { handleAfterLeave() {
this.$el.removeEventListener('transitionend', this.destroyElement);
this.$destroy(true); this.$destroy(true);
this.$el.parentNode.removeChild(this.$el); this.$el.parentNode.removeChild(this.$el);
}, },