element UI Notification通知上添加按钮和点击事件

需求:消息通知的时候需要有更多的点击按钮,进行跳转

            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;

添加button 和添加a标签一样
跳转的时候要将通知关闭

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

猜你喜欢

转载自blog.csdn.net/qq_32881447/article/details/112766816