element UI中Notification 通知防重叠以及关闭通知问题

//好的 不再提示
    neirong1(i){
          const h = this.$createElement;  //vue 中的渲染函数  createElement 参数
          var that = this;
          that.notifyPromise = that.notifyPromise.then(that.$nextTick).then(function () {  //防止通知叠加
          let notify =that.$notify({   
          title: that.msgNotify[i].title,
          customClass:'sss',    //给最外层div加class
          message: h('p', null, [          //消息中除了标题所有的dom写在[]中
            h('div', null, that.msgNotify[i].digest),
              h('el-button', {
                style: {
                  margin:'15px 5px 10px 100px',
                },
                attrs: {
                  size: 'mini',
                  type: 'primary'
                },
                on: {
                click:function(){
                  console.log(that.msgNotify[i].id)
                  request({
                    url: '/sp/message/spBG/isRead',
                    method: 'get',
                    params:{id:that.msgNotify[i].id}
                  }).then(res => {
                    that.msgNotifyList[that.msgNotify[i].id].close() //关闭通知
                    if(that.msgNotify[i].isRead==0){
                      that.$store.state.user.num1--  
                    }
                  })
                  }
                }
              }, '好的'),
              h('el-button', {
                style: {
                  margin:'10px 5px',
                //  float: 'right'
                },
                attrs: {
                  size: 'mini',
                  type: 'primary'
                },
                on: {
                click:function(){
                  console.log(that.msgNotify[i].id)
                  request({
                    url: '/sp/message/spBG/isPopout',
                    method: 'get',
                    params:{id:that.msgNotify[i].id}
                  }).then(res => {
                    that.msgNotifyList[that.msgNotify[i].id].close()  //找到该id对应的某个notify关闭
                  })
                  }
                }
              }, '不再提示')
        ]),
        position: 'top-right',  //通知在页面的显示位置
        duration: 0, 
        offset: 20,
        dangerouslyUseHTMLString: true
        })
        that.msgNotifyList[that.msgNotify[i].id]=notify    //把每个通知都放进msgNotifyList中,例如{id:某个notify}
      })
    },

防止通知重叠进行的异步操作

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值