关闭功能及如何处理多个通知

exprot default {
	data() {
     return {
	  //使用userNotifyId作为弹窗的key,用来获取弹窗的实例,以对对应弹窗进行操作
      notifications: {}
	 }
    },
	methods: {
    	// 打开一个新的通知
    	openNotify(userNotification) {
    	 // userNotification 中的userNotifyId是唯一的
    	 const h = this.$createElement
         let notify= this.$notify.success({
           title: data.notification.notifyName,
           dangerouslyUseHTMLString: true,
           position: 'bottom-right',
           message: h(
            'p',
            {
              // 相当于`v-bind:style`
              style: {
                color: 'red',
                fontSize: '14px'
              },
              class: 'pointer',
              on: {
                click: () => {
                  this.closeNotification(
                    data.notification.data.message,
                    data.userNotifyId,
                  )
                }
              }
            },
            data.notification.data.message
          ),
          duration: 60 * 1000
        })
        this.notifications[data.userNotifyId] = notify
     },
    
     //关闭单个通知
     closeNotification(message, id){
      this.notifications[id].close();
      delete this.notifications[id];
     },
    
     // 关闭所有通知
     closeAllNotification(){
      for (let key in this.notifications) {
        this.notifications[key].close();
        delete this.notifications[key];
      }
    }
   }
}
  
GitHub 加速计划 / eleme / element
14
2
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:2 个月前 )
c345bb45 1 年前
a07f3a59 * Update transition.md * Update table.md * Update transition.md * Update table.md * Update transition.md * Update table.md * Update table.md * Update transition.md * Update popover.md 1 年前
Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐