I set up a flag foundInBrowser that informs me whether the entry 'aaa' is present in localStorage. Clicking on an input toggle adds/removes the entry, which in turn automatically updates the flag:
<template>
<q-toggle
v-model="foundInBrowser"
checked-icon="check"
color="red"
:label="`${foundInBrowser ? '' : 'not'} registered in browser`"
unchecked-icon="clear"
@click="registerInBrowser"
/>
</template>
<script>
const registerInBrowser = () => {
// toggle the existance of the localstorage entry
if (foundInBrowser.value) {
localStorage.removeItem('aaa')
} else {
localStorage.setItem('aaa', person.value?.ID as string)
}
}
const foundInBrowser = computed(() => localStorage.getItem('aaa') !== null)
</script>
When clicking on the toggle, I get an error in the console:
Write operation failed: computed value is readonly
I do not understand this error: I am not trying to write to foundInBrowser anywhere.