• element中Notification组件(this.$notify)自定义样式


    1、自定义样式效果 

    2、vue代码 

    1. this.notifications = this.$notify({
    2. title: '',
    3. dangerouslyUseHTMLString: true,
    4. duration: obj.remindMethod === '3' ? 0 : 4500,
    5. customClass: 'notify-warning',
    6. offset: 50,
    7. showClose: false,
    8. message: this.$createElement(
    9. "div",
    10. null,
    11. [
    12. this.$createElement(
    13. "div",
    14. { class: 'alertTile' }
    15. ),
    16. this.$createElement(
    17. "div",
    18. { class: 'alertTile_1' },
    19. "报警"
    20. ),
    21. this.$createElement(
    22. "div",
    23. { class: 'alertContant' },
    24. [
    25. this.$createElement(
    26. "el-tooltip",
    27. {
    28. props:{
    29. effect:'dark',
    30. content: obj.data,
    31. placement:'top'
    32. },
    33. },
    34. [
    35. this.$createElement(
    36. "span",
    37. { class: 'alertContantSpan' },
    38. "报警内容" + ":" + obj.data
    39. ),
    40. ]
    41. ),
    42. this.$createElement(
    43. "div",
    44. "报警时间:" + obj.time
    45. ),
    46. ]
    47. ),
    48. this.$createElement(
    49. "button",
    50. {
    51. class: 'close_notify',
    52. on: {
    53. click: _this.closeNotify.bind(_this, obj),
    54. },
    55. },
    56. obj.buttonName
    57. ),
    58. ]
    59. ),
    60. });

     3、CSS、不能用scoped修饰

    1. <style>
    2. .el-notification__content {
    3. margin-top:30px
    4. }
    5. .notify-warning {
    6. background-image: url("../../../assets/images/baojing_box_red.png") !important;
    7. background-size: 100% 100% !important;
    8. width: 420px !important;
    9. height: 120px !important;
    10. background-position-y: 0px !important;
    11. background-color: rgba(255, 255, 255, 0) !important;
    12. margin-top: 50px !important;
    13. border: none !important;
    14. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 0) !important;
    15. }
    16. .el-notification__group {
    17. margin-left: 130px !important;
    18. }
    19. .alertTile_1 {
    20. position: absolute !important;
    21. background-image: url("../../../assets/images/alert_red_3.png") !important;
    22. width: 128px !important;
    23. height: 128px !important;
    24. left: 0px !important;
    25. top: 0px !important;
    26. border-radius: 64px !important;
    27. color: white !important;
    28. line-height: 128px !important;
    29. text-align: center !important;
    30. position: relative;
    31. font-size: 16px !important;
    32. }
    33. .alertTile {
    34. position: absolute !important;
    35. background-image: url("../../../assets/images/alert_red_1.png") !important;
    36. width: 128px !important;
    37. height: 128px !important;
    38. left: 0px !important;
    39. top: 0px !important;
    40. border-radius: 64px !important;
    41. color: white !important;
    42. line-height: 128px !important;
    43. text-align: center !important;
    44. position: relative;
    45. -webkit-transform: rotate(360deg);
    46. animation: myfirst 3s linear infinite;
    47. -moz-animation: myfirst 3s linear infinite;
    48. -webkit-animation: myfirst 3s linear infinite;
    49. -o-animation: myfirst 3s linear infinite;
    50. font-size: 16px !important;
    51. }
    52. .alertContant{
    53. word-wrap:break-word;
    54. color:white;
    55. }
    56. @-webkit-keyframes myfirst {
    57. from {
    58. -webkit-transform: rotate(360deg);
    59. }
    60. to {
    61. -webkit-transform: rotate(0deg);
    62. }
    63. }
    64. .el-notification__closeBtn{
    65. top:25px
    66. }
    67. .close_notify{
    68. color: #fff;
    69. cursor: pointer;
    70. width: 50px;
    71. height: 22px;
    72. line-height: 20px;
    73. background: #0f83f7;
    74. text-align: center;
    75. position: absolute;
    76. bottom: 15px;
    77. right: 5px;
    78. }
    79. style>

    4、自定义关闭按钮

    1. //点击事件回调
    2. closeNotify(type) {
    3. console.log("hahah");
    4. console.log(type);
    5. if(type === '2'){
    6. console.log("自动关闭,流程。。");
    7. }
    8. if(type === '3'){
    9. console.log("手动确认,流程。。");
    10. }
    11. this.notifications.close();
    12. },

    5、使用到的图片

    alert_red_1.png
    alert_red_2.png
    alert_red_3.png
    baojing_box_red.png
    baojing_content_red.png

    图片地址链接:

    https://download.csdn.net/download/askuld/88282624

  • 相关阅读:
    办理400电话客服中心的申请步骤及注意事项
    下载遥感数据慢的原因
    开源笔记leanote搭建记录
    DOM--预加载和懒加载
    大三第十周学习笔记
    光格科技递交科创板上会稿:拟募资6亿 预计年营收3亿
    软考中级(网络工程师考核要点)第一章 计算机网络系统(信道特性应用)第六期(4B/5B编码、数字调制技术和脉冲编码调制)
    jmeter压力测试工具,雪崩效应,容错组件Sentinel
    Flutter 单元测试例子
    1. Tailwind CSS 简介
  • 原文地址:https://blog.csdn.net/askuld/article/details/132619318