layout-footer.vue
803 Bytes
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
<script setup lang="ts">
import type { CSSProperties } from 'vue';
import { computed } from 'vue';
interface Props {
/**
* 是否固定在底部
*/
fixed?: boolean;
height: number;
/**
* 是否显示
* @default true
*/
show?: boolean;
width: string;
zIndex: number;
}
const props = withDefaults(defineProps<Props>(), {
show: true,
});
const style = computed((): CSSProperties => {
const { fixed, height, show, width, zIndex } = props;
return {
height: `${height}px`,
marginBottom: show ? '0' : `-${height}px`,
position: fixed ? 'fixed' : 'static',
width,
zIndex,
};
});
</script>
<template>
<footer
:style="style"
class="bottom-0 w-full bg-background-deep transition-all duration-200"
>
<slot></slot>
</footer>
</template>