BasicLoading.vue
1.29 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
<template>
<section class="basic-loading">
<img
src="/@/assets/images/loading.svg"
alt=""
:height="getLoadingIconSize"
:width="getLoadingIconSize"
/>
<span class="mt-4" v-if="tip"> {{ tip }}</span>
</section>
</template>
<script lang="ts">
import type { PropType } from 'vue';
// components
import { defineComponent, computed } from 'vue';
// hook
import { SizeEnum, sizeMap } from '/@/enums/sizeEnum';
import { BasicLoadingProps } from './type';
export default defineComponent({
inheritAttrs: false,
name: 'BasicLoading',
props: {
tip: {
type: String as PropType<string>,
default: '',
},
size: {
type: String as PropType<SizeEnum>,
default: SizeEnum.DEFAULT,
validator: (v: SizeEnum): boolean => {
return [SizeEnum.DEFAULT, SizeEnum.SMALL, SizeEnum.LARGE].includes(v);
},
},
},
setup(props: BasicLoadingProps) {
const getLoadingIconSize = computed(() => {
const { size } = props;
return sizeMap.get(size);
});
return { getLoadingIconSize };
},
});
</script>
<style lang="less" scoped>
.basic-loading {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
</style>