1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| <template> <!-- 遮罩层 也是整个组件的容器--> <div class="pop-container" v-if="isShow"> <div class="message-container"> <!-- 两个icon放在一个容器中,但是只显示一个 --> <div class="icon-container"> <div class="icon-container-success" v-if="type === 'success'"> <!-- 引用了iview的Icon组件 --> <Icon class="icon-checkmark" type="md-checkmark" size="30" color="#D8DCE9" /> </div> <div class="icon-container-error" v-if="type === 'error'"> <Icon class="icon-close" type="md-close" size="30" color="#D8DCE9" /> </div> </div> <span class="message-text">{{ text }}</span> </div> </div> </template>
<script> export default { name: 'message', props: { type: { // type控制是成功还是失败 type: String, default: 'success', }, text: { // 弹窗的文字信息 type: String, default: '', }, isShow: { // 整个遮罩和弹窗是否显示 type: Boolean, default: true, }, }, }; </script>
<style scoped lang="less"> .pop-container { display: flex; justify-content: center; align-items: center;
z-index: 99999; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(24, 30, 53, 0.7); backdrop-filter: blur(10px); } .message-container { display: flex; justify-content: center; align-items: center; min-width: 384px; padding: 0 30px; height: 170px; background: #303e62; box-shadow: 0px 0px 30px rgba(0, 0, 0, 0.1); border-radius: 12px; } .icon-container { position: relative; height: 40px; width: 40px; border-radius: 50%; &-error { background-color: #fe1b1b; height: 40px; width: 40px; border-radius: 50%; .icon-close { position: absolute; right: 5px; bottom: 5px; font-weight: 900; } } &-success { background-color: #4ad991; height: 40px; width: 40px; border-radius: 50%; .icon-checkmark { position: absolute; right: 4px; bottom: 5px; font-weight: 900; } } } .message-text { margin-left: 12px; font-weight: 500; font-size: 18px; line-height: 27px; } </style>
|