Skip to content

How to pass parameters to the function in getters #688

@myfreax

Description

@myfreax

store

export default  new Vuex.Store({
   getters:{
    search(state,keyword){
      //return state.items; //first question
     //second question
      return state.items.filter(item =>{
        return item.name === keyword
      });
    }
  }
})

component

  export default {
    name: 'items',
    computed: {
      search () {
        return this.$store.getters.search
      }
    }
  }

1.It don't work,why? According to this document
2.How to pass parameters to the function in getters?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions