当前位置: 首页 > news >正文

【Element】通知 Notification

ElementUI

弹出通知

created() {const h = this.$createElementconst that = thisthis.$notify({onClose: function () {that.do()},type: 'warning',duration: 5000, // 5秒后隐藏offset: 0, // 距离顶部dangerouslyUseHTMLString: false, showClose: false,customClass: 'notify-msg',message: h('div', { class: 'notify-msg-box', },[h('div', { class: 'notify-msg-top' }, [h('div', { class: 'notify-msg-title' }, '标题标题'),h('div', { class: 'notify-msg-time' }, '2022-22-21 12:12:12'),]),h('div', { class: 'notify-msg-content' }, '内容内容'),])})
}
<style lang="scss">
.notify-msg {padding: 15px;width: 400px;.el-notification__group {flex: 1;margin-right: 0;}.el-notification__icon {margin-top: 5px;}.notify-msg-box {margin: 0 0 20px;padding: 0;.notify-msg-top {display: flex;align-items: flex-start;justify-content: space-between;margin: 0;}.notify-msg-title {font-size: 16px;color: #333333;margin-bottom: 5px;text-overflow: ellipsis;overflow: hidden;white-space: nowrap;flex: 1;word-break: break-all;width: 150px;}.notify-msg-time {padding-left: 9px;padding-right: 20px;color: #666666;font-size: 14px;width: 160px;text-align: right;}.notify-msg-content {font-size: 14px;color: #333333;}}
}
</style>

 

created() {let str = ``let list = [1, 2, 3, 4]list.forEach((v) => {str += `<div class="notify-msg-box"><div class="notify-msg-top"><div class="notify-msg-title">标题标题</div><div class="notify-msg-time">2022-22-21 12:12:12</div></div><div class="notify-msg-content">内容内容</div></div>`})this.$notify({type: 'warning',duration: 5000,offset: 0,dangerouslyUseHTMLString: true,showClose: true,customClass: 'notify-msg',message: str})
}

created() {let list = [1,2,3,4]list.forEach((v) => {this.$notify({type: 'warning',duration: 5000,offset: 10,dangerouslyUseHTMLString: true,showClose: true,customClass: 'notify-msg',message: `<div class="notify-msg-box"><div class="notify-msg-top"><div class="notify-msg-title">标题标题</div><div class="notify-msg-time">2022-22-21 12:12:12</div></div><div class="notify-msg-content">内容内容</div></div>`})})
}

解决

data() {return {notifyPromise: Promise.resolve()}
},
created() {let list = [1,2,3,4]list.forEach((v) => {let msg = `<div class="notify-msg-box"><div class="notify-msg-top"><div class="notify-msg-title">标题标题</div><div class="notify-msg-time">2022-22-21 12:12:12</div></div><div class="notify-msg-content">内容内容</div></div>`this.notify(msg)})
},
notify(msg) {this.notifyPromise = this.notifyPromise.then(this.$nextTick).then(() => {this.$notify({type: 'warning',duration: 5000,// offset: 0,dangerouslyUseHTMLString: true,showClose: true,customClass: 'notify-msg',message: msg})})
}

http://www.lryc.cn/news/173871.html

相关文章:

  • vue+express、gitee pm2部署轻量服务器(20230923)
  • 前端教程-H5游戏开发
  • Nginx 关闭/屏蔽 PUT、DELETE、OPTIONS 请求
  • 【React】React概念、特点和Jsx基础语法
  • 大数据的崭露头角:数据湖与数据仓库的融合之道
  • 用go实现cors中间件
  • Linux 链表示例 LIST_INIT LIST_INSERT_HEAD
  • 【机器学习】详解回归(Regression)
  • mac 配置 httpd nginx php-fpm 详细记录 已解决
  • Angular 项目升级需要注意什么?
  • 开发高性能知识付费平台:关键技术策略
  • python图像匹配:如何使用Python进行图像匹配
  • R语言绘制PCA双标图、碎石图、变量载荷图和变量贡献图
  • Jolokia 笔记 (Kafka/start/stop)
  • Qt5开发及实例V2.0-第十九章-Qt.QML编程基础
  • 固定开发板的ifconfig的IP地址
  • 停车场系统源码
  • R语言贝叶斯MCMC:GLM逻辑回归、Rstan线性回归、Metropolis Hastings与Gibbs采样算法实例...
  • 若依前后端分离如何解决匿名注解启动报错?
  • Spring面试题4:面试官:说一说Spring由哪些模块组成?说一说JDBC和DAO之间的联系和区别?
  • 【再识C进阶3(上)】详细地认识字符串函数、进行模拟字符串函数以及拓展内容
  • docker启动mysql8目录挂载改动
  • CHATGPT中国免费网页版有哪些-CHATGPT中文版网页
  • docker network create命令
  • 4G版本云音响设置教程腾讯云平台版本
  • Grafana离线安装部署以及插件安装
  • 非独立随机变量的概率上界估计
  • 常见电子仪器及其用途
  • 配置测试ip、正式ip、本地ip
  • Linux 系统移植(一)-- 系统组成