2023-04-07 10:34:35 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
const state = useState(() => shallowRef({} as Record<string, any>))
|
2023-05-30 11:53:04 +00:00
|
|
|
const nonDisplayedState = useState(() => shallowRef({} as Record<string, any>))
|
2023-04-07 10:34:35 +00:00
|
|
|
|
|
|
|
if (process.server) {
|
|
|
|
const r = ref('')
|
|
|
|
state.value.ref = r
|
|
|
|
state.value.shallowReactive = shallowReactive({ nested: { ref: r } })
|
|
|
|
state.value.shallowRef = shallowRef(false)
|
2023-05-13 19:49:05 +00:00
|
|
|
state.value.undefined = shallowRef()
|
2023-04-07 10:34:35 +00:00
|
|
|
state.value.reactive = reactive({ ref: r })
|
|
|
|
state.value.error = createError({ message: 'error' })
|
|
|
|
state.value.date = new Date()
|
2023-05-30 11:53:04 +00:00
|
|
|
nonDisplayedState.value.bigint = 0n
|
|
|
|
nonDisplayedState.value.bigintRef = ref(0n)
|
2023-04-07 10:34:35 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<pre>{{ state }}</pre>
|
|
|
|
Date: {{ state.date instanceof Date }} <br>
|
2023-05-30 11:53:04 +00:00
|
|
|
BigInt: {{ nonDisplayedState.bigint === 0n }} <br>
|
2023-04-07 10:34:35 +00:00
|
|
|
Error: {{ isNuxtError(state.error) }} <hr>
|
|
|
|
Shallow reactive: {{ isReactive(state.shallowReactive) && isShallow(state.shallowReactive) }} <br>
|
|
|
|
Shallow ref: {{ isShallow(state.shallowRef) }} <br>
|
2023-05-13 19:49:05 +00:00
|
|
|
Undefined ref: {{ isRef(state.undefined) }} <br>
|
2023-05-30 11:53:04 +00:00
|
|
|
BigInt ref: {{ isRef(nonDisplayedState.bigintRef) && typeof nonDisplayedState.bigintRef.value === 'bigint' }} <br>
|
2023-04-07 10:34:35 +00:00
|
|
|
Reactive: {{ isReactive(state.reactive) }} <br>
|
|
|
|
Ref: {{ isRef(state.ref) }} <hr>
|
|
|
|
Recursive objects: {{ state.ref === state.shallowReactive.nested.ref }} <br>
|
|
|
|
</div>
|
|
|
|
</template>
|