DESKTOP-CVS3R96\我恁爹
2022-11-07 940d76fdc141d7028918fbe30adb1bb3935a2b54
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
<!--  -->
<template>
    <el-alert v-show="alertShow" :closable="closable" :title="texts" :type="elType" center>
    </el-alert>
</template>
 
<script>
export default {
    props: {
        alertShow: {
            type: Boolean,
            default: false
        },
        closable: {
            type: Boolean,
            default: false
        },
        texts: {
            type: String,
            default: ''
        },
        elType: {
            type: String,
            default: 'warning'
        }
    },
    data() {
        return {
 
        }
    },
    //监听alertShow变成true时,2秒后自动关闭
    watch: {
        alertShow: function (val) {
            if (val) {
                setTimeout(() => {
                    this.$emit('closeAlert')
                }, 2000)
            }
        }
    },
    //生命周期 - 创建完成(访问当前this实例)
    created() {
 
    },
    //生命周期 - 挂载完成(访问DOM元素)
    mounted() {
 
    },
    methods:{
        //定时调用父组件方法关闭弹窗
        closeAlert(){
            //定时调用父组件方法关闭弹窗
            setTimeout(()=>{
                this.$emit('closeAlert')
            },2000)
        }
        
    }
}
</script>
<style scoped lang="less">
/* @import url(); 引入css类 */
/deep/.el-alert{
  width: 70%!important;
  height: 1rem!important;
  position: absolute!important;
  top: 0!important;
  bottom: 0!important;
  left: 0!important;
  right: 0!important;
  margin: auto!important;
  font-size: 0.3rem!important;
}
/deep/.el-alert__title{
  font-size: 0.3rem!important;
}
</style>