模态框组件
Showing
3 changed files
with
153 additions
and
4 deletions
| ... | @@ -6,6 +6,69 @@ import { | ... | @@ -6,6 +6,69 @@ import { |
| 6 | 6 | ||
| 7 | 7 | ||
| 8 | export default { | 8 | export default { |
| 9 | props: { | ||
| 10 | // 是否显示组件 | ||
| 11 | visible: { | ||
| 12 | type: Boolean, | ||
| 13 | default: true, | ||
| 14 | }, | ||
| 15 | // 标题名称 需要再 assets/images/common/ 目录下添加图标 | ||
| 16 | icon: { | ||
| 17 | type: String, | ||
| 18 | default: "succ", | ||
| 19 | }, | ||
| 20 | // 标题,不建议使用 | ||
| 21 | title: { | ||
| 22 | type: String, | ||
| 23 | default: "", | ||
| 24 | }, | ||
| 25 | // 文案 | ||
| 26 | content: { | ||
| 27 | type: String, | ||
| 28 | default: "", | ||
| 29 | }, | ||
| 30 | // 确认文案 | ||
| 31 | confirmText: { | ||
| 32 | type: String, | ||
| 33 | default: "確認", | ||
| 34 | }, | ||
| 35 | // 取消文案 | ||
| 36 | cancelText: { | ||
| 37 | type: String, | ||
| 38 | default: "取消", | ||
| 39 | }, | ||
| 40 | // 是否显示确认按钮 | ||
| 41 | showConfirm: { | ||
| 42 | type: Boolean, | ||
| 43 | default: true, | ||
| 44 | }, | ||
| 45 | // 是否显示取消按钮 | ||
| 46 | showCancel: { | ||
| 47 | type: Boolean, | ||
| 48 | default: true, | ||
| 49 | }, | ||
| 50 | // 是否显示遮罩层 | ||
| 51 | overlayShow: { | ||
| 52 | type: Boolean, | ||
| 53 | default: true, | ||
| 54 | }, | ||
| 55 | |||
| 56 | // 确定按钮回调方法 | ||
| 57 | confirm: { | ||
| 58 | type: Function, | ||
| 59 | default: null | ||
| 60 | }, | ||
| 61 | // 取消按钮回调方法 | ||
| 62 | cancel: { | ||
| 63 | type: Function, | ||
| 64 | default: null | ||
| 65 | }, | ||
| 66 | // 点击蒙层回调方法 | ||
| 67 | overlay: { | ||
| 68 | type: Function, | ||
| 69 | default: null | ||
| 70 | } | ||
| 71 | }, | ||
| 9 | data() { | 72 | data() { |
| 10 | return { | 73 | return { |
| 11 | key: 'value' | 74 | key: 'value' |
| ... | @@ -13,9 +76,26 @@ export default { | ... | @@ -13,9 +76,26 @@ export default { |
| 13 | }, | 76 | }, |
| 14 | components: {}, | 77 | components: {}, |
| 15 | methods: { | 78 | methods: { |
| 79 | // 点击确认 | ||
| 80 | onConfirmHandler() { | ||
| 81 | if (this.confirm) { | ||
| 82 | this.confirm(); | ||
| 83 | } | ||
| 84 | }, | ||
| 85 | // 点击取消 | ||
| 86 | onCancelHandler() { | ||
| 87 | if (this.cancel) { | ||
| 88 | this.cancel(); | ||
| 89 | } | ||
| 90 | }, | ||
| 91 | // 点击蒙层 | ||
| 92 | onOverLayHandler() { | ||
| 93 | if (this.overlay) { | ||
| 94 | this.overlay(); | ||
| 95 | } | ||
| 96 | }, | ||
| 16 | initData() {} | 97 | initData() {} |
| 17 | }, | 98 | }, |
| 18 | mounted() {}, | 99 | mounted() {}, |
| 19 | created() { | 100 | created() {} |
| 20 | } | ||
| 21 | } | 101 | } | ... | ... |
| 1 | @import '@/styles/_support'; | 1 | @import '@/styles/_support'; |
| 2 | |||
| 3 | .comp { | ||
| 4 | position: absolute; | ||
| 5 | z-index: 999; | ||
| 6 | width: 100%; | ||
| 7 | height: 100%; | ||
| 8 | @extend .fcc; | ||
| 9 | text-align: center; | ||
| 10 | } | ||
| 11 | |||
| 12 | .overlay { | ||
| 13 | position: absolute; | ||
| 14 | width: 100%; | ||
| 15 | height: 100%; | ||
| 16 | background: rgba($color: #000000, $alpha: 0.7); | ||
| 17 | } | ||
| 18 | |||
| 19 | .modal { | ||
| 20 | position: relative; | ||
| 21 | @extend .bb; | ||
| 22 | width: 36rem; | ||
| 23 | min-height: 22.5rem; | ||
| 24 | border-radius: 1.25rem; | ||
| 25 | background-color: #ffffff; | ||
| 26 | padding: 4.5rem 2rem 2.5rem; | ||
| 27 | |||
| 28 | &-title { | ||
| 29 | margin-bottom: 3rem; | ||
| 30 | color: $cOrange; | ||
| 31 | font-size: 24px; | ||
| 32 | font-weight: bold; | ||
| 33 | } | ||
| 34 | |||
| 35 | &-icon-wrap { | ||
| 36 | @extend .fcc; | ||
| 37 | } | ||
| 38 | |||
| 39 | &-content { | ||
| 40 | color: $cOrange; | ||
| 41 | font-size: 18px; | ||
| 42 | font-weight: bold; | ||
| 43 | } | ||
| 44 | |||
| 45 | &-btn-wrap { | ||
| 46 | display: flex; | ||
| 47 | justify-content: center; | ||
| 48 | |||
| 49 | .btn { | ||
| 50 | @include btc2(12rem, 3.6rem, 16px); | ||
| 51 | margin: 2rem 1rem 0; | ||
| 52 | @extend .pointer; | ||
| 53 | } | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | .hide{ | ||
| 58 | display: none; | ||
| 59 | } | ... | ... |
| 1 | 1 | ||
| 2 | <template> | 2 | <template> |
| 3 | <div class="comp"> | 3 | <div class="comp" :class="{'hide' : !visible }"> |
| 4 | modal-comp | 4 | <div @click="onOverLayHandler()" class="overlay" v-if="overlayShow"></div> |
| 5 | <div class="modal"> | ||
| 6 | <div v-if="title" class="modal-title">{{title}}</div> | ||
| 7 | <div class="modal-icon-wrap"> | ||
| 8 | <img :src="require('@assets/images/common/icon-'+icon+'.png')"> | ||
| 9 | </div> | ||
| 10 | <div class="modal-content">{{content}}</div> | ||
| 11 | <div class="modal-btn-wrap"> | ||
| 12 | <div @click="onCancelHandler()" v-if="showCancel" class="btn">{{cancelText}}</div> | ||
| 13 | <div @click="onConfirmHandler()" v-if="showConfirm" class="btn">{{confirmText}}</div> | ||
| 14 | </div> | ||
| 15 | </div> | ||
| 5 | </div> | 16 | </div> |
| 6 | </template> | 17 | </template> |
| 7 | 18 | ... | ... |
-
Please register or sign in to post a comment