vue(element-ui组件) 的this.$notify的具体使用

javascript 复制代码
        getNotify() {
      this.noClose();
      let message = "";
      message = this.itemData.map((ele) => {
        const text = "任务" + ele.title + "新增" + ele.num + "条言论";
        return this.$createElement(
          "el-tooltip",
          {
            props: {
              content: text,
              placement: "top",
              disabled: text.length >= 34 ? false : true,
            },
            class: "item",
          },
          [
            this.$createElement(
              "div",
              {
                class: "detailText",
                on: {
                  click: () => this.skipDetails(ele),
                },
              },
              [
                this.$createElement("span", "任务"),
                this.$createElement(
                  "span",
                  { style: { color: "red" } },
                  `"` + ele.title + `"`
                ),
                this.$createElement("span", "新增"),
                this.$createElement(
                  "span",
                  { style: { color: "red" } },
                  ele.num
                ),
                this.$createElement("span", "条言论"),
              ]
            ),
          ]
        );
      });
      this.notifications = this.$notify({
        dangerouslyUseHTMLString: true,
        position: "bottom-right",
        duration: 0,
        showClose: false,
        message: this.$createElement(
          "div",
          {
            class: "contentAll",
            on: {
              scroll: () => this.onScroll, // 直接绑定滚动事件
            },
          },
          [
            this.$createElement(
              "div",
              { class: "contentHead" },
              // "这里是头部内容"
              [
                this.$createElement("div", { class: "my-custom-icon" }),
                this.$createElement(
                  "div",
                  { class: "my-custom-text" },
                  "预警通知"
                ),
                this.$createElement("div", {
                  class: "el-icon-close my-custom-close",
                  on: {
                    click: this.noClose.bind(),
                  },
                }),
              ]
            ),
            this.$createElement("div", { class: "contentDeatil" }, message),
          ]
        ),
      });
      setTimeout(() => {
        const _this = this;
        if (document.getElementsByClassName("contentAll")[0]) {
          document
            .getElementsByClassName("contentAll")[0]
            .addEventListener("mouseenter", _this.handleMouseEnter);
        }
      }, 20);
    },

注意:1、写css样式不能加scoped 要在后面加上 !important才生效

css 复制代码
  .contentAll {
    position: fixed;
  right: 0px;
  bottom: 0px;
  background-color: #fff;
  z-index: 2000 !important;
  width: 359px !important;
    .contentHead {
      width: 100%;
      height: 40px !important;
      background-color: #0087ff;
      display: flex;
      flex-direction: row;
      align-items: center;
      position: relative;
      padding-left: 20px;
      box-sizing: border-box;
      .my-custom-icon {
        width: 20px !important;
        height: 20px !important;
        background-image: url("~assets/images/allwarning/warning.png");
        background-size: cover;
        background-repeat: no-repeat;
        background-position: center center;
      }
      .my-custom-text {
        font-size: 18px;
        color: #ffffff;
        margin-left: 10px;
      }
      .my-custom-close {
        font-size: 18px;
        color: #ffffff;
        position: absolute;
        right: 15px;
        cursor: pointer;
      }
    }
    .contentDeatil {
      min-height: 100px !important;
      max-height: 280px !important;
      padding-left: 20px !important;
      padding-right: 20px !important;
      box-sizing: border-box;
      overflow: auto;
      .detailText {
        width: 100%;
        font-size: 16px !important;
        line-height: 30px !important;
        margin-top: 15px !important;
        margin-bottom: 15px !important;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        &:hover {
          text-decoration: underline;
          cursor: pointer;
        }
      }
    }
  }

2、大家有什么问题,可以在评论区评论

相关推荐
^^为欢几何^^6 分钟前
lodash中_.difference如何过滤数组
javascript·数据结构·算法
Hello-Mr.Wang10 分钟前
vue3中开发引导页的方法
开发语言·前端·javascript
程序员凡尘38 分钟前
完美解决 Array 方法 (map/filter/reduce) 不按预期工作 的正确解决方法,亲测有效!!!
前端·javascript·vue.js
北岛寒沫5 小时前
JavaScript(JS)学习笔记 1(简单介绍 注释和输入输出语句 变量 数据类型 运算符 流程控制 数组)
javascript·笔记·学习
everyStudy5 小时前
JavaScript如何判断输入的是空格
开发语言·javascript·ecmascript
无心使然云中漫步6 小时前
GIS OGC之WMTS地图服务,通过Capabilities XML描述文档,获取matrixIds,origin,计算resolutions
前端·javascript
Bug缔造者6 小时前
Element-ui el-table 全局表格排序
前端·javascript·vue.js
xnian_7 小时前
解决ruoyi-vue-pro-master框架引入报错,启动报错问题
前端·javascript·vue.js
罗政7 小时前
[附源码]超简洁个人博客网站搭建+SpringBoot+Vue前后端分离
vue.js·spring boot·后端
麒麟而非淇淋8 小时前
AJAX 入门 day1
前端·javascript·ajax