UNPKG

1.11 kBPlain TextView Raw
1<template>
2 <div class="overlay" v-show="visible" :style="{position: type}">
3 <div class="box">
4 <img width="20" src="../assets/images/loading2.gif">
5 </div>
6 </div>
7</template>
8<script>
9export default {
10 data() {
11 return {
12 visible: false
13 };
14 },
15 props: {
16 show: {
17 default: false,
18 type: Boolean
19 },
20 // 至少显示多少毫秒
21 min: {
22 type: Number,
23 default: 100
24 },
25 type: {
26 type: String,
27 default: "fixed"
28 }
29 },
30 watch: {
31 show(val) {
32 if (val) {
33 this.visible = true;
34 } else {
35 if (this.min === 0) {
36 this.visible = false;
37 return;
38 }
39 setTimeout(() => {
40 this.visible = false;
41 }, this.min);
42 }
43 }
44 }
45};
46</script>
47<style scoped>
48.overlay {
49 position: fixed;
50 top: 0;
51 left: 0;
52 width: 100%;
53 height: 100%;
54 background: white;
55}
56.box {
57 width: 20px;
58 height: 20px;
59 margin: auto;
60 position: absolute;
61 left: 0;
62 right: 0;
63 bottom: 0;
64 top: 0;
65}
66</style>