vue中使用element ui,进入页面左下角强制弹窗

7 篇文章 0 订阅
5 篇文章 0 订阅

两种方法:

layout/index页面
一种是样式用ul,li,会自动落下

template(html)部分

<div class="floatclass">
      <ul
        class="box-card alarmRedBar"
        v-for="(item, index) in noticeList"
        :key="index"
      >
        <el-button
          type="text"
          class="textClose"
          @click="close(item)"
          icon="el-icon-circle-close"
        >
        </el-button>
        <li class="text item">信息名称: {{ item.message}}</li></li>
      </ul>
    </div>

第二种:循环触发for循环
template(html)部分:

<div class="floatclass">
      <el-card
        class="box-card"
        v-for="(item, index) in noticeList"
        :key="index"
      >
        <div class="text item">计划名称: {{ item.message}}</div>
      </el-card>
    </div>

methods方法代码:

 //关闭
 close(ite) {
      this.noticeList.some((item, i) => {
        if (item.planId == ite.planId) {
          this.noticeList.splice(i, 1);
          // 在数组的some方法中,如果return true,就会立即终止这个数组的后续循环,所以相比较foreach,如果想要终止循环,那么建议使用some
          return true;
        }
      });
    },
 getNoticeList() {
      getNoticeList().then((res) => {
        if (res.code == 200) {
          this.noticeList = res.rows;
          for (var i = 0; i < this.noticeList.length; i++) {
            this.open(i,this.noticeList[i]);
          }
        }
      });
    },
    open(i,noticeList) {
      const h = this.$createElement;
      this.$notify({
        title: "标题名称",
        message:noticeList.message,
        position:"bottom-left",
        offset:i * 80
      });
    },

css部分:

.floatclass {
  display: flex;
  -ms-flex-pack: center;
  flex-wrap: wrap;
  flex-direction: column;
  position: absolute;
  left: -200px;
  bottom: 5px;
}
.alarmRedBar {
  width: 200px;
  height: 88px;
  /* position: absolute;
  cursor: move;
  top: 89%;
  left: 1%; */
  z-index: 1001;
}
ul {
  /* margin: 0; */
  margin: 2px 2px;
  padding: 0;
}
.el-button--medium.is-round {
  padding: 3px 14px;
  font-size: 13px;
}
.el-button--medium {
  font-size: 13px;
}
ul li {
  list-style-type: none;
}
.textClose {
  float: right;
  margin-top: -11px;
  margin-right: 5px;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值