Syntax question: localstorage has(key) method
-
I’m confused by what the documentation says about the has(key) method. I don’t understand how to use it.
It says: “Name
has (key) => Boolean
Description
Check if storage item exists”I’m trying to include the “has” method in a method of my own, something like this:
getListener(){
if(this.$q.localStorage.has(“listener”)){
this.listener = this.$q.localStorage.getItem(“listener”)
}
}Obviously, that doesn’t work, but what does work?
-
Obviously, that doesn’t work, but what does work?
rude, but works fine here https://codepen.io/metalsadman/pen/ZEQQXpx check the source and console.maybe you didn’t add the plugin https://quasar.dev/quasar-plugins/web-storage#Installation, or your key
listener
is not set yet, also check the notes and tips section in that docs. -
<sigh> You’re right. I didn’t add it as a plugin. Thanks!