Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

258
Vistas
Can't access getters in the store for Vue when in a template because it "is not a function"

I'm new to vue and vuex and I'm also using Nuxt. I want to use a function in my template that searches for some data that I fetched from an API (in vuex). I can't figute out why I always get

state.allHandhelds.values.findIndex is not a function

My template is like this:

<div>{{ handheldID("Form Factor") }}</div>

And in my computed I call the function like this:

 computed: {
    ...mapGetters(["allHandhelds"]),
    handheldID(merkmal) {
      return this.$store.getters.indexFinder(merkmal);
    },
  },

In vuex I have it defined as a getter:

export const getters = {
   indexFinder(state, merkmal) {
    return state.allHandhelds.values.findIndex(
      (el) => el === merkmal
    ); /* Index des Merkmals finden */
  },
};

Any idea where I'm going wrong with that?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You've to use the method access style like :

export const getters = {

 indexFinder: (state) => (merkmal) => {
      return state.allHandhelds.values.findIndex(
         (el) => el === merkmal
    ); 
  }
};

or with syntax :

export const getters = {
   indexFinder(state) {
    return (merkmal)=> {
       return state.allHandhelds.values.findIndex(
      (el) => el === merkmal
    ); /* Index des Merkmals finden */
   }  
},
};
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda