Add button and click events to element UI Notification notification

Requirements: There need to be more click buttons to jump when receiving message notifications

            const h = this.$createElement;
            const notify = this.$notify({
    
    
              title: data.type,
              message: h(
                "p",
                {
    
    
                  style:"width: 250px;display: flex;justify-content: space-between;",
                },
                [
                  h("span", null, data.content),
                  h(
                    "a",
                    {
    
    
                      style: "color: #409EFF;cursor: pointer;",
                      on: {
    
    
                        click: this.goToMore,
                      },
                    },
                    "更多"
                  ),
                ]
              ),
              position: "bottom-right",
              type: "warning",
              duration: 10000,
              customClass: "custom-class",
            });
            this.notify[data.id] = notify;

Adding a button is the same as adding a tag.
You need to turn off the notification when jumping.

 goToMore() {
    
    
      let _this = this;
      for (let key in _this.notify) {
    
    
        _this.notify[key].close();
        delete _this.notify[key];
      } //关闭全部通知
      this.$router.push("/earlyWarning/index");
    },

Guess you like

Origin blog.csdn.net/qq_32881447/article/details/112766816