Element的Notification通知自定义样式手动关闭直接渲染带html格式的字符串
效果图:
功能点1:弹窗需要自定义样式,例如实现滚动条展示多条数据
答:其实简单的自定义样式可以使用官网提供的:message
属性支持传入 HTML 片段
不过我用的是 createElement,这个的使用方法具体用法可以参考这篇博客:
[Vue]createElement参数 - vickylinj - 博客园
功能点2:渲染数据的时候不能,挤在一起,而要能将数组里的数据换行显示
答:后端返回的数据是一个数组类型,所以我需要将数组遍历出来加上换行符号</br>,所以这里要用到createElement的DOM属性
功能点3:要能区分弹窗是自动关闭的?还是手动点击按钮关闭的?
答:因为就算手动调用弹窗的关闭方法,一样会执行onClose的关闭回调,所以压根没法区分是点击了X关闭按钮还是我弹窗自己定时关闭的。所以我是将弹窗的关闭按钮隐藏,自己画了一个上去,然后监听这个的点击事件
代码:写的有点乱,将就看吧 哈哈哈哈哈
// 在data中定义个弹窗实例
data () {return {instance: null // 通知弹窗实例}}---------------------------------------------------------------------------------this.instance = this.$notify({dangerouslyUseHTMLString: true,showClose: false, // 关闭自带的关闭按钮duration: 0, position: 'bottom-right',customClass: 'notifyClass',// 这个样式只能放在无scoped的style中才能生效message: this.$createElement('div',{},[this.$createElement('div',{ class: 'notify_div' },[this.$createElement('div',{ class: 'notify_title' },[this.$createElement('i',{ class: 'el-icon-bell notifyIcon' }),this.$createElement('span',{},'通知')]),this.$createElement('i',{ class: 'el-icon-close', on: { click: this.closeNotify } })]),this.$createElement('div',{domProps: {innerHTML: htmlString // htmlString就是带HTML格式的字符串'<em>你好啊</em>'},class: 'notifyContent'})])})
----------------------------------------------------------------------------------------closeNotify () {this.instance.close() // 手动关闭通知}----------------------------------------------------------------------
.notifyClass {background-color: #fdf6ec;
}
.notify_title {margin-bottom: 5px;font-weight: bold;
}
.notifyContent {color: #f75343;height: 100px;overflow-y: auto;padding-right: 6px;&::-webkit-scrollbar {width: 5px;height: 7px;background-color: #fff;}&::-webkit-scrollbar-track {border-radius: 10px;background-color: #fff;}&::-webkit-scrollbar-thumb {height: 20px;border-radius: 10px;background-color: #cccdd1;}
}
.notifyIcon {color: #f75343;margin-right: 5px;
}
.notify_div {display: flex;justify-content: space-between;
}
Element的Notification通知自定义样式手动关闭直接渲染带html格式的字符串相关推荐
- 利用element显示Notification通知,复制提醒,禁用F12或右键菜单提醒
大家在设定网站提示消息时,非常推荐这个element显示Notification通知功能. 使用方法: 一.引入cdn资源 <!-- 引入VUE --> <script src=&q ...
- element ui table show-overflow-tooltip自定义样式
element ui table show-overflow-tooltip自定义样式 在使用element ui table 组件时,表格td内容太多可设置show-overflow-tooltip ...
- 原生html使用element组件,使用element-ui的table组件时,渲染为html格式
背景 今天在做vue的项目时,使用到 element-ui 的 table 组件,使用富文本编辑器进行新增操作后,发现 html格式 并没有被识别 原因 在 element-ui 中,table组件默 ...
- 【黑马Android】(11)音乐播放器/视频播放器/照相机/常见对话框/notification通知/样式和主题/帧动画/传感器/应用程序反编译与安装
音乐播放器api <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns: ...
- 适配 通知 Notification 通知渠道 前台服务 MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...
- Android的notification通知
概括: Android使用notification实现消息提醒,提供通知栏和通知抽屉查看通知和通知详情,Android的notification机制应用非常广泛,是指在应用程序之外显示的消息,布局由系 ...
- u盘自动打开html,如何快速禁用U盘自动弹出(播放)功能无需手动关闭弹出窗口
如何快速禁用U盘自动弹出(播放)功能无需手动关闭弹出窗口 发布时间:2013-08-26 17:04:27 作者:佚名 我要评论 移动硬盘分了N个区的时候需要手动一个一个的关掉自动播放窗口,真 ...
- android自定义通知栏样式,Android 通知栏自定义样式
8.0系统的通知栏适配 在8.0之前我们通知栏的使用:notification = new NotificationCompat.Builder(mContext) .setWhen(System.c ...
- Android学习|控件——Notification通知
Android学习|控件--Notification通知 一.前提 二.两个对象的的构建 1.创建NotificationManager 2.使用Builder构造器来创建Notification 2 ...
最新文章
- 2014年:这些词都快被玩坏了
- PostgreSQL 表达式索引 - 语法注意事项
- Python之二叉树的遍历
- #1407 : 后缀数组二·重复旋律2 (不可重叠最长重复子串问题)
- 【Django】文件上传以及celery的使用
- git分支指的是_Git分支是什么
- 微信和QQ,终于可以互通了
- 三节点潮流计算matlab,电力系统分析大作业matlab三机九节点潮流计算报告.doc
- MCS-51单片机总体概述(一)
- ZOJ 4093 浙大校赛D题 Robot Cleaner II(思维+构造题)
- 台式计算机的显卡,台式电脑显卡天梯图-台式机显卡性能排名
- 计算机的网线连接路由器的什么接口,tp-link路由器网线插哪个口 tplink路由器网线连接图解...
- OSChina 周一乱弹 —— 妮儿还是把上衣穿上吧
- 2022下半年软考-中级-软件设计师-过关经验
- 常系数非齐次微分方程特解及其通解求解
- 2023年3月华为认证HCIP新增题库(考试编号H12-821)
- @Around对静态方法不生效问题
- matlab 将mat格式的数据另存为Excel数据(xls,xlsx)
- CSS命名规范 BEM
- 三级菜单-输出各省各市各县各镇