zengh
2022-05-09 52c39f5e2711e5535b689b66dfa5e100c7882b7f
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
<template>
    <!-- escloud -->
    <view>
        <view :class="[value? 'show': '']" class="yy-modal" id="show" @click="closeModal">
            <!-- click.stop 阻止<slot>中的点击事件继续向外传播,
            避免触发最外层closeModal点击事件 -->
            <div @click.stop class='content'>
                <slot></slot>
            </div>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                show: false
            };
        },
        props:{
            value: {
                type: [Boolean, String],
                default: false
            }
        },
        watch: {
            value(val) {
                if (val) {
                    this.show = val
                } else {
                    this.handleHidden()
                }
            }
        },
        methods:{
            closeModal(e){
                this.$emit('input', false)
            },
            handleHidden(){
                setTimeout(()=> {
                    this.show = false
                }, 300)
            }
        }
    }
</script>
 
<style scoped lang="scss">
.yy-modal{
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    opacity: 0;
    transform: scale(1.185);
    pointer-events: none;
    transition: all 0.3s ease-in-out 0s;
    background: rgba(0,0,0,0.6);
}
.show{
    opacity: 1;
    transition-duration: 0.3s;
    transform: scale(1);
    overflow-x: hidden;
    overflow-y: auto;
    pointer-events: auto;
 
}
.content{
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    border-radius: 15rpx;
    overflow: hidden;
}
 
</style>