No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Syntax question: localstorage has(key) method

    Framework
    2
    3
    141
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • O
      omgwalt last edited by

      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?

      metalsadman 1 Reply Last reply Reply Quote -1
      • metalsadman
        metalsadman @omgwalt last edited by metalsadman

        @omgwalt

        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.

        1 Reply Last reply Reply Quote 0
        • O
          omgwalt last edited by

          <sigh> You’re right. I didn’t add it as a plugin. Thanks!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post