使用element的Notification做消息推送 样式重叠

一、解决element-ui,同时调用notification时,通知重叠的问题

data(){
    return {
     notificationPromise:Promise.resolve()}
},
methods:{
    notify(msg) {
        this.notificationPromise = this.notificationPromise.then(this.$nextTick).then(()=>{
          this.$notify({
            title: "消息",
            message: msg,
            dangerouslyUseHTMLString: true,
            duration: 0
          })
        })
      }
}
<script>

二、自定义notification的显示样式,点击事件

   notify(msg) {
      const h = this.$createElement
      this.notifyPromise = this.notifyPromise.then(this.$nextTick).then(() => {
        let notify = this.$notify({
          title: "",
          // message: msg.F_Content,
          message: h('p', [
            h('p', null, '你有一个新的待办' + msg.F_Title),
            h('i', {
              class: 'el-icon-close footerClose',
              on: {
                click: () => {
                  this.closeNotify(msg); //关闭事件
                },
              },
            }, ''),
            h('p', {
              style: 'text-align: right;width:195px;dispaly:block;margin-top: 8px;color:#43c39d;cursor: pointer;',
              on: {
                click: () => {
                  this.clickNotify(msg);//点击事件详情
                },
              },
            }, '点击查看详情'),
          ]),
          position: 'bottom-right',
          dangerouslyUseHTMLString: true,
          duration: 0,
          showClose: false,
          // onClick: this.clickNotify(msg)

        });
        this.notifications[msg.F_Id] = notify; //存储消息列表的数据,调用本身的close事件实现关闭
        //记录还有几个弹窗没有关闭(方便任何一个页面关闭)
        this.$store.commit('CLOSE_NOTICE', this.notifications)
      })

    },

1.关闭单个消息通知

代码如下(示例):

  closeNotification(msg) {
      this.notifications[msg.F_Id].close();
      delete this.notifications[msg.F_Id];
    },

2.关闭所有消息通知

代码如下(示例):

  closeAllNotification() {
      let _this = this;
      for (let key in _this.notifications) {
        _this.notifications[key].close()
        delete _this.notifications[key];
      }
    },

总结

提示:这里对文章进行总结:
例如:以上就是分享element 的notifications通知组件自定义事件 样式
消息通知

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值