forked from nuxt/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client-only-components.vue
60 lines (57 loc) · 1.92 KB
/
client-only-components.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
51
52
53
54
55
56
57
58
59
60
<template>
<div>
<ClientScript ref="clientScript" class="client-only-script" foo="bar" />
<ClientSetupScript
ref="clientSetupScript"
class="client-only-script-setup"
foo="hello"
>
<template #test>
<div class="slot-test">
Hello
</div>
</template>
</ClientSetupScript>
<ClientOnly>
Should not be server rendered.
<template #fallback>
<div>Fallback</div>
</template>
</ClientOnly>
<!-- ensure multi root node components are correctly rendered (Fragment) -->
<ClientMultiRootNode class="multi-root-node" />
<ClientMultiRootNodeScript class="multi-root-node-script" />
<!-- ensure components with a single single child are correctly rendered -->
<ClientStringChildStateful ref="stringStatefulComp" class="string-stateful" />
<ClientStringChildStatefulScript
ref="stringStatefulScriptComp"
class="string-stateful-script"
/>
<!-- ensure directives are correctly passed -->
<ClientStringChildStateful v-show="false" class="string-stateful-should-be-hidden" />
<ClientSetupScript v-show="false" class="client-script-should-be-hidden" foo="bar" />
<ClientStringChildStatefulScript
v-show="false"
class="string-stateful-script-should-be-hidden"
/>
<ClientNoState class="no-state" />
<button class="test-ref-1" @click="stringStatefulComp.add">
increment count
</button>
<button class="test-ref-2" @click="stringStatefulScriptComp.add">
increment count
</button>
<button class="test-ref-3" @click="clientScript.add">
increment count
</button>
<button class="test-ref-4" @click="clientSetupScript.add">
increment count
</button>
</div>
</template>
<script setup lang="ts">
const stringStatefulComp = ref(null)
const stringStatefulScriptComp = ref(null)
const clientScript = ref(null)
const clientSetupScript = ref(null)
</script>