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

    Can't acess state from Vuex

    Help
    3
    6
    377
    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.
    • B
      braganca last edited by

      Hello,

      I am getting started with Quasar and been trying to integrate it with Vuex, but unfortunately, I am not able to access de state from …mapState nor $store.state. I get an error saying ‘[Vue warn]: Error in v-on handler: “TypeError: Cannot read property ‘loadedLogbook’ of undefined”’

      Here is my store.js: https://pastebin.com/dXrThh8W
      The component: https://pastebin.com/38j9cREk
      logbook/index.js https://pastebin.com/PJczXLLm
      State: https://pastebin.com/sfA2i1mm
      Getters https://pastebin.com/bzwFyAcH
      Mutation https://pastebin.com/UqFmGqp9
      Actions https://pastebin.com/MCeNTxLA

      I am able to visualize the date from Vue Devtools as of this image:
      I am able to visualize the date from Vue Devtools as of this image

      1 Reply Last reply Reply Quote 0
      • metalsadman
        metalsadman last edited by

        @braganca mapState and mapGetters should be in computed not in methods. Please refer to vuex docs.

        1 Reply Last reply Reply Quote 0
        • J
          JackyLee last edited by JackyLee

          @metalsadman I’m trying to use quasar new store newModule to add the Vuex manually today for my new Quasar project, it generates the newModule for me, but no the index.js config file, Could it do as the Quasar CLI works to generates the index.js config file also?

          1 Reply Last reply Reply Quote 0
          • metalsadman
            metalsadman last edited by

            @JackyLee the cli command just creates the module and files for you, you still have to register the module in your src/store/index module object.
            ie.

            //src/store/index.js
            import newModule from './newModule'
            ...
              modules: {
               newModule
              }
            ...
            
            1 Reply Last reply Reply Quote 0
            • J
              JackyLee last edited by

              @metalsadman the problem is not such file src/store/index generated after run the command! If the quasar new store newModule could add both src/store/index and src/store/module will be be better.

              1 Reply Last reply Reply Quote 0
              • metalsadman
                metalsadman last edited by metalsadman

                @JackyLee nope, its not automated. If you didnt include vuex when you were creating your project the first time, just create a new project running quasar create with vuex, then just copy the store/index.js file into your actual project.

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