Nuxt/test/fixtures/basic/pages/client-only-page/index.client.vue

35 lines
591 B
Vue
Raw Normal View History

2024-03-06 14:38:39 +00:00
<script setup lang="ts">
const state = useState('test', () => {
let hasAccessToWindow = null as null | boolean
try {
hasAccessToWindow = !!Object.keys(window).at(0)
2024-03-06 14:38:39 +00:00
} catch {
hasAccessToWindow = null
}
return {
hasAccessToWindow,
isServer: import.meta.server
}
})
const serverRendered = useState(() => import.meta.server)
</script>
<template>
<div>
<NuxtLink to="/client-only-page/normal">
normal
</NuxtLink>
<p id="state">
{{ state }}
</p>
<p id="server-rendered">
{{ serverRendered }}
</p>
</div>
</template>