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 access state through mutation in VUEX?

    Help
    2
    3
    376
    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.
    • S
      smajli last edited by

      I am following the suggested store file structure. Inside mutations.js I have :
      export function UPDATE_PAID_MONTHLY_EXPENSES(state , key){
      //state.paidMonthlyExpenses = […state.paidMonthlyExpenses, key]
      I am trying to add an item to an array like in above commented code. but It doesn’t work. So I tried console logging the state from inside this function and the state is an {__ ob __: Observer} object . I can see the state as an object in devTools if I expand the object, but I can’t access anything from it, if I try to, it still counts as another { __ ob __: Observer}. Can someone help me fix this.
      }

      I also think that the the state, might actually be a module, so thats why you can have state.state, but I even tried that, but it still gives me { __ ob __ : Observer }

      0_1551664391108_ec1a81f2-1b84-4c1b-9beb-47eeead62038-image.png

      0_1551664435322_526d4eac-9a5e-4ce4-9b30-f34b6160b06a-image.png

      0_1551664470593_05676732-9ecd-4799-8d37-c30a40d75321-image.png

      1 Reply Last reply Reply Quote 0
      • M
        morlz last edited by

        Your state is similar to

        const state = {
          state: {
            paidMonthlyExpenses: []
          }
        }
        

        You should set it like (two times “state”)

        state.state.paidMonthlyExpenses = [...state.state.paidMonthlyExpenses, key]
        
        S 1 Reply Last reply Reply Quote 1
        • S
          smajli @morlz last edited by

          @morlz You deserve a truck load of beer ❤ . Thanks a lot for helping me out I appreciate it.

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