0 votes
in VueJS by
What is a method style access?

1 Answer

0 votes
by
You can access store's state in a method style by passing arguments.

For example, you can pass user id to find user profile information as below,

getters: {

  getUserProfileById: (state) => (id) => {

    return state.users.find(user => user.id === id)

  }

}

After that you can access it as a method call,

store.getters.getUserProfileById(111); {id: '111', name: 'John', age: 33}

Related questions

0 votes
asked Sep 12, 2023 in VueJS by AdilsonLima
0 votes
asked Sep 15, 2023 in VueJS by JackTerrance
...