返回 slidev
Modal.vue
根目录 / packages / client / internals / Modal.vue
1 <script setup lang="ts">
2 import { useVModel } from '@vueuse/core'
3
4 const props = defineProps({
5 modelValue: {
6 default: false,
7 },
8 class: {
9 default: '',
10 },
11 })
12
13 const emit = defineEmits(['update:modelValue'])
14 const value = useVModel(props, 'modelValue', emit)
15
16 function onClick() {
17 value.value = false
18 }
19 </script>
20
21 <template>
22 <KeepAlive>
23 <div v-if="value" class="fixed top-0 bottom-0 left-0 right-0 grid z-modal">
24 <div
25 bg="black opacity-80"
26 class="absolute top-0 bottom-0 left-0 right-0 -z-1"
27 @click="onClick()"
28 />
29 <div
30 class="m-auto rounded-md bg-main shadow"
31 dark:border="~ main"
32 :class="props.class"
33 >
34 <slot />
35 </div>
36 </div>
37 </KeepAlive>
38 </template>
39
39 lines Plain Text