drawer.vue
1.24 KB
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
<template>
<div class="drawer" :class="{'drawer-open': on }" v-show="on">
<div class="drawer-main" v-el:main>
<slot></slot>
</div>
<div class="drawer-mask" @click="close"></div>
</div>
</template>
<script>
module.exports = {
props: {
on: Boolean
},
methods: {
close() {
this.on = false;
}
},
watch: {
on(newVal) {
if(newVal) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = '';
}
}
}
};
</script>
<style>
.drawer {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.drawer-mask {
position: absolute;
z-index: 199;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.6);
}
.drawer-main {
position: absolute;
z-index: 200;
top: 0;
right: 0%;
bottom: 0;
min-width: 80%;
max-width: 100%;
background-color: #fff;
transition: all 0.3s 0.2s;
}
</style>