Kaynağa Gözat

Notification: add onClick handler

Alexandre Mouillard 8 yıl önce
ebeveyn
işleme
d51f08870d
1 değiştirilmiş dosya ile 10 ekleme ve 2 silme
  1. 10 2
      packages/notification/src/main.vue

+ 10 - 2
packages/notification/src/main.vue

@@ -6,7 +6,8 @@
       v-show="visible"
       :style="{ top: top ? top + 'px' : 'auto' }"
       @mouseenter="clearTimer()"
-      @mouseleave="startTimer()">
+      @mouseleave="startTimer()"
+      @click="click">
       <i
         class="el-notification__icon"
         :class="[ typeClass, iconClass ]"
@@ -15,7 +16,7 @@
       <div class="el-notification__group" :class="{ 'is-with-icon': typeClass || iconClass }">
         <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 class="el-notification__closeBtn el-icon-close" @click.stop="close"></div>
       </div>
     </div>
   </transition>
@@ -40,6 +41,7 @@
         customClass: '',
         iconClass: '',
         onClose: null,
+        onClick: null,
         closed: false,
         top: null,
         timer: null
@@ -68,6 +70,12 @@
         this.$el.parentNode.removeChild(this.$el);
       },
 
+      click() {
+        if (typeof this.onClick === 'function') {
+          this.onClick();
+        }
+      },
+
       close() {
         this.closed = true;
         if (typeof this.onClose === 'function') {