綁定參數:
alertText ⇒ String ⇒ required
發射事件:
closeTip ⇒ 無資料
<template>
<div class="alert-container">
<section class="tip-text-container">
<div class="tip-icon"></div>
<p class="tip-text">{{ alertText }}</p>
<div class="confirm" @click="closeTip">確認</div>
</section>
</div>
</template>
<script>
export default {
name: 'AlertTip',
props: {
alertText: {
type: String,
required: true
}
},
methods: {
closeTip() {
this.$emit('closeTip') // 分發字定義事件( 事件: clostTip )
}
}
}
</script>
<style lang="scss" scoped>
@keyframes tip-move {
0% {
transform: scale(1);
}
35% {
transform: scale(0.8);
}
70% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
.alert-container {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 999;
background: rgba(0, 0, 0, 0.5);
> .tip-text-container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 60%;
animation: tip-move 0.4s;
border: 1px;
padding-top: 20px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
border-radius: 5px;
background-color: #fff;
> .tip-icon {
width: 55px;
height: 55px;
margin: 20px 0;
border: 2px solid red;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
&:after {
content: "\\2716";
font-size: 24px;
color: red;
}
}
> .tip-text {
font-size: 14px;
font-weight: 700;
letter-spacing: 1px;
color: #333;
line-height: 20px;
text-align: center;
margin: 10px 0 20px;
padding: 0 5px;
}
> .confirm {
font-size: 18px;
font-weight: 900;
letter-spacing: 1px;
background-color: blue;
width: 100%;
text-align: center;
padding: 10px 0;
color: #fff;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
}
}
</style>