-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
/
Copy pathVaporComp.vue
50 lines (44 loc) · 1.28 KB
/
VaporComp.vue
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
<script setup vapor lang="ts">
import { ref } from 'vue'
import VdomComp from './VdomComp.vue'
defineProps<{
msg: string
}>()
const ok = ref(true)
const passSlot = ref(true)
const slotProp = ref('slot prop')
</script>
<template>
<div class="vapor" style="border: 2px solid red; padding: 10px">
<h2>This is a Vapor component in VDOM</h2>
<p class="vapor-prop">props.msg: {{ msg }}</p>
<button @click="ok = !ok">Toggle slots</button>
<div v-if="ok" style="border: 2px solid orange; padding: 10px">
<h3>vdom slots in vapor component</h3>
<button
class="change-vdom-slot-in-vapor-prop"
@click="slotProp = 'changed'"
>
change slot prop
</button>
<div class="vdom-slot-in-vapor-default">
#default: <slot :foo="slotProp" />
</div>
<div class="vdom-slot-in-vapor-test">
#test: <slot name="test">fallback content</slot>
</div>
</div>
<button
class="toggle-vapor-slot-in-vdom-default"
@click="passSlot = !passSlot"
>
Toggle default slot to vdom
</button>
<VdomComp :msg="msg">
<template #default="{ foo }" v-if="passSlot">
<div>slot prop: {{ foo }}</div>
<div>component prop: {{ msg }}</div>
</template>
</VdomComp>
</div>
</template>