mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-05 03:47:12 +00:00
33 lines
1.1 KiB
Vue
33 lines
1.1 KiB
Vue
<script setup>
|
|
useCookie('accessed-but-not-used')
|
|
useCookie('accessed-with-default-value', () => 'default')
|
|
useCookie('set').value = 'set'
|
|
useCookie('set-to-null').value = null
|
|
useCookie('set-to-null-with-default', () => 'default').value = null
|
|
|
|
// the next set are all sent by browser
|
|
useCookie('browser-accessed-but-not-used')
|
|
useCookie('browser-accessed-with-default-value', () => 'default')
|
|
useCookie('browser-set').value = 'set'
|
|
useCookie('browser-set-to-null').value = null
|
|
useCookie('browser-set-to-null-with-default', () => 'default').value = null
|
|
|
|
const objectCookie = useCookie('browser-object-default')
|
|
const objectCookieSecond = useCookie('browser-object-default', {
|
|
default: () => ({ foo: 'bar' }),
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<div>
|
|
<div>cookies testing page</div>
|
|
<pre>{{ objectCookieSecond.foo }}</pre>
|
|
<button @click="objectCookie.foo === 'baz' ? objectCookie.foo = 'bar' : objectCookie.foo = 'baz'">
|
|
Change cookie
|
|
</button>
|
|
<button @click="refreshCookie('browser-object-default')">
|
|
Refresh cookie
|
|
</button>
|
|
</div>
|
|
</template>
|