index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <script setup name="Dialog">
  2. defineProps({
  3. show: {
  4. type: Boolean,
  5. default: false
  6. },
  7. title: {
  8. type: String,
  9. default: '标题名称'
  10. },
  11. message: {
  12. default: '这是一段内容'
  13. },
  14. close: {
  15. type: Function,
  16. default: fun => fun()
  17. }
  18. })
  19. </script>
  20. <template>
  21. <div v-if="show" class="dialog-mask custom-dialog">
  22. <div class="dialog-box">
  23. <div class="dialog-header">
  24. <p class="el-message-box__title">{{title}}</p>
  25. </div>
  26. <p class="dialog-content">{{message}}</p>
  27. <div class="dialog-footer">
  28. <button class="el-button primary small" @click="close">確認</button>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <style lang="scss" scoped>
  34. .dialog-mask {
  35. position: fixed;
  36. left: 0;
  37. top: 0;
  38. width: 100%;
  39. height: 100%;
  40. background: rgba(0, 0, 0, 0.5);
  41. z-index: 9999;
  42. display: flex;
  43. justify-content: center;
  44. align-items: center;
  45. .dialog-box {
  46. display: inline-block;
  47. min-width: 420px;
  48. padding-bottom: 10px;
  49. vertical-align: middle;
  50. background-color: #fff;
  51. border-radius: 4px;
  52. border: 1px solid #ebeef5;
  53. font-size: 18px;
  54. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  55. text-align: left;
  56. overflow: hidden;
  57. backface-visibility: hidden;
  58. .dialog-header {
  59. position: relative;
  60. padding: 15px 15px 10px;
  61. .el-message-box__title{
  62. padding-left: 0;
  63. margin-bottom: 0;
  64. font-size: 18px;
  65. line-height: 1;
  66. color: #303133;
  67. }
  68. }
  69. .dialog-content {
  70. padding: 10px 15px;
  71. color: #606266;
  72. font-size: 14px;
  73. white-space: pre-wrap;
  74. word-wrap: break-word;
  75. }
  76. .dialog-footer {
  77. padding: 5px 15px 0;
  78. text-align: right
  79. }
  80. }
  81. }
  82. .el-button{
  83. display: inline-block;
  84. line-height: 1;
  85. white-space: nowrap;
  86. cursor: pointer;
  87. background: #fff;
  88. border: 1px solid #dcdfe6;
  89. color: #606266;
  90. appearance:none;
  91. -webkit-appearance: none;
  92. text-align: center;
  93. box-sizing: border-box;
  94. outline: none;
  95. margin: 0;
  96. transition: .1s;
  97. font-weight: 500;
  98. user-select:none;
  99. -moz-user-select: none;
  100. -webkit-user-select: none;
  101. -ms-user-select: none;
  102. padding: 12px 20px;
  103. font-size: 14px;
  104. border-radius: 4px;
  105. &.primary{
  106. color: #fff;
  107. background-color: #409eff;
  108. border-color: #409eff;
  109. }
  110. &.small{
  111. padding: 9px 15px;
  112. font-size: 12px;
  113. border-radius: 3px;
  114. }
  115. }
  116. </style>