-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
/
Copy pathApp.vue
44 lines (38 loc) · 1.1 KB
/
App.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
<script setup lang="ts">
import { ref, defineVaporAsyncComponent, h } from 'vue'
import VaporComp from './components/VaporComp.vue'
import VdomFoo from './components/VdomFoo.vue'
const msg = ref('hello')
const passSlot = ref(true)
const duration = typeof process !== 'undefined' && process.env.CI ? 200 : 50
const AsyncVDomFoo = defineVaporAsyncComponent({
loader: () => {
return new Promise(r => {
setTimeout(() => {
r(VdomFoo as any)
}, duration)
})
},
loadingComponent: () => h('span', 'loading...'),
})
</script>
<template>
<input v-model="msg" />
<button class="toggle-vdom-slot-in-vapor" @click="passSlot = !passSlot">
toggle #test slot
</button>
<VaporComp :msg="msg">
<template #default="{ foo }">
<div>slot prop: {{ foo }}</div>
<div>component prop: {{ msg }}</div>
</template>
<template #test v-if="passSlot">A test slot</template>
</VaporComp>
<!-- async component -->
<div class="async-component-interop">
<div class="with-vdom-component">
<AsyncVDomFoo />
</div>
</div>
<!-- async component end -->
</template>