FrontendDeveloper.in

Vue.js question detail

What is a method style access?

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}
Back to all Vue.js questions
Get LinkedIn Premium at Rs 399