2022-11-24 12:24:14 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
const islandProps = ref({
|
|
|
|
bool: true,
|
|
|
|
number: 100,
|
|
|
|
str: 'helo world',
|
|
|
|
obj: { json: 'works' }
|
|
|
|
})
|
|
|
|
|
2023-05-15 22:43:53 +00:00
|
|
|
const showIslandSlot = ref(false)
|
2022-11-24 12:24:14 +00:00
|
|
|
const routeIslandVisible = ref(false)
|
2023-05-15 22:43:53 +00:00
|
|
|
const testCount = ref(0)
|
2023-03-20 21:47:06 +00:00
|
|
|
const count = ref(0)
|
2022-11-24 12:24:14 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
Pure island component:
|
|
|
|
<div class="box">
|
2023-11-09 17:01:13 +00:00
|
|
|
<NuxtIsland
|
|
|
|
name="PureComponent"
|
|
|
|
:props="islandProps"
|
|
|
|
/>
|
|
|
|
<NuxtIsland
|
|
|
|
name="PureComponent"
|
|
|
|
:props="islandProps"
|
|
|
|
/>
|
2022-11-24 12:24:14 +00:00
|
|
|
</div>
|
2023-11-09 17:01:13 +00:00
|
|
|
<button
|
|
|
|
id="increase-pure-component"
|
|
|
|
@click="islandProps.number++"
|
|
|
|
>
|
2022-11-24 12:24:14 +00:00
|
|
|
Increase
|
|
|
|
</button>
|
|
|
|
<hr>
|
|
|
|
Route island component:
|
2023-11-09 17:01:13 +00:00
|
|
|
<div
|
|
|
|
v-if="routeIslandVisible"
|
|
|
|
class="box"
|
|
|
|
>
|
|
|
|
<NuxtIsland
|
|
|
|
name="RouteComponent"
|
|
|
|
:context="{ url: '/test' }"
|
|
|
|
/>
|
2022-11-24 12:24:14 +00:00
|
|
|
</div>
|
2023-11-09 17:01:13 +00:00
|
|
|
<button
|
|
|
|
v-else
|
|
|
|
id="show-route"
|
|
|
|
@click="routeIslandVisible = true"
|
|
|
|
>
|
2022-11-24 12:24:14 +00:00
|
|
|
Show
|
|
|
|
</button>
|
2023-03-20 21:47:06 +00:00
|
|
|
|
|
|
|
<p>async .server component</p>
|
2023-05-15 22:43:53 +00:00
|
|
|
<AsyncServerComponent :count="count">
|
|
|
|
<div id="slot-in-server">
|
|
|
|
Slot with in .server component
|
|
|
|
</div>
|
|
|
|
</AsyncServerComponent>
|
|
|
|
<div>
|
|
|
|
Async component (1000ms):
|
|
|
|
<div>
|
2023-11-09 17:01:13 +00:00
|
|
|
<NuxtIsland
|
|
|
|
name="LongAsyncComponent"
|
|
|
|
:props="{ count }"
|
|
|
|
>
|
2023-05-15 22:43:53 +00:00
|
|
|
<div>Interactive testing slot</div>
|
|
|
|
<div id="first-sugar-counter">
|
2023-11-27 23:02:02 +00:00
|
|
|
<Counter :multiplier="testCount" />
|
2023-05-15 22:43:53 +00:00
|
|
|
</div>
|
|
|
|
<template #test="scoped">
|
|
|
|
<div id="test-slot">
|
|
|
|
Slot with name test - scoped data {{ scoped }}
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template #hello="scoped">
|
|
|
|
<div id="test-slot">
|
|
|
|
Slot with name hello - scoped data {{ scoped }}
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</NuxtIsland>
|
2023-11-09 17:01:13 +00:00
|
|
|
<button
|
|
|
|
id="update-server-components"
|
|
|
|
@click="count++"
|
|
|
|
>
|
2023-05-15 22:43:53 +00:00
|
|
|
add +1 to count
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-03-20 21:47:06 +00:00
|
|
|
<div>
|
2023-05-15 22:43:53 +00:00
|
|
|
<p>Island with props mounted client side</p>
|
2023-11-09 17:01:13 +00:00
|
|
|
<button
|
|
|
|
id="show-island"
|
|
|
|
@click="showIslandSlot = true"
|
|
|
|
>
|
2023-05-15 22:43:53 +00:00
|
|
|
Show Interactive island
|
2023-03-20 21:47:06 +00:00
|
|
|
</button>
|
2023-05-15 22:43:53 +00:00
|
|
|
<div id="island-mounted-client-side">
|
2023-11-09 17:01:13 +00:00
|
|
|
<NuxtIsland
|
|
|
|
v-if="showIslandSlot"
|
|
|
|
name="LongAsyncComponent"
|
|
|
|
:props="{ count }"
|
|
|
|
>
|
2023-05-15 22:43:53 +00:00
|
|
|
<div>Interactive testing slot post SSR</div>
|
2023-11-27 23:02:02 +00:00
|
|
|
<Counter :multiplier="testCount" />
|
2023-05-15 22:43:53 +00:00
|
|
|
</NuxtIsland>
|
|
|
|
</div>
|
2023-03-20 21:47:06 +00:00
|
|
|
</div>
|
2023-12-19 12:21:29 +00:00
|
|
|
<ServerWithClient />
|
2022-11-24 12:24:14 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.box {
|
|
|
|
border: 1px solid black;
|
|
|
|
margin: 3px;
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
</style>
|