customModal.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <!--
  2. 这里是自定义展示框组件,自定义标题、内容、两个按钮
  3. 张志宏 调整删除提示框,使用自定义组件
  4. 24.9.6
  5. -->
  6. <template>
  7. <view class="modal-container" v-if="visible">
  8. <!-- 遮盖罩 -->
  9. <view class="modal-overlay" @click="close"></view>
  10. <!-- 提示栏内容 -->
  11. <view class="modal-content">
  12. <view class="modal-title">{{ title }}</view>
  13. <view class="modal-body">{{ content }}</view>
  14. <view class="modal-buttons">
  15. <button @click="onCancel" class="cancel-btn">{{ cancelText }}</button>
  16. <button @click="onConfirm" class="confirm-btn">{{ confirmText }}</button>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. props: {
  24. visible: Boolean,
  25. title: String,
  26. content: String,
  27. confirmText: String,
  28. cancelText: String
  29. },
  30. methods: {
  31. close() {
  32. this.$emit('update:visible', false);
  33. },
  34. onConfirm() {
  35. this.$emit('confirm');
  36. this.close();
  37. },
  38. onCancel() {
  39. this.$emit('cancel');
  40. this.close();
  41. }
  42. }
  43. };
  44. </script>
  45. <style scoped>
  46. .modal-container {
  47. position: fixed;
  48. top: 0;
  49. left: 0;
  50. right: 0;
  51. bottom: 0;
  52. display: flex;
  53. align-items: center;
  54. justify-content: center;
  55. z-index: 1000;
  56. border-radius: 40px;
  57. }
  58. /* 遮盖罩样式 */
  59. .modal-overlay {
  60. position: absolute;
  61. top: 0;
  62. left: 0;
  63. right: 0;
  64. bottom: 0;
  65. background-color: rgba(0, 0, 0, 0.5);
  66. z-index: 999; /* 确保遮罩在内容下层 */
  67. }
  68. .modal-content {
  69. padding: 20px;
  70. border-radius: 8px;
  71. width: 300px;
  72. max-width: 90%;
  73. background: #ffffff;
  74. z-index: 1000; /* 确保遮罩在内容上层 */
  75. }
  76. .modal-title {
  77. font-size: 40px;
  78. font-weight: bold;
  79. margin-bottom: 15px;
  80. }
  81. .modal-body {
  82. font-size: 30px;
  83. margin-bottom: 20px;
  84. }
  85. .modal-buttons {
  86. display: flex;
  87. justify-content: space-between;
  88. }
  89. .confirm-btn, .cancel-btn {
  90. flex: 1;
  91. padding: 2px;
  92. margin: 8px;
  93. background: transparent; /* 背景透明 */
  94. font-size: 36px;
  95. border: 2px solid #dbdada;
  96. }
  97. .confirm-btn {
  98. border-radius: 20px;
  99. color: #eb9d9a;
  100. }
  101. .cancel-btn {
  102. border-radius: 20px;
  103. color: #9ee493;
  104. }
  105. </style>