Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
Cómo iterar sobre un vue getter

Tengo este captador this.getHouseTypes , devuelve una matriz con objetos de la tienda vuex.

Pero ahora quiero agregar 1 elemento a la matriz de la manera más corta, así que estaba pensando en ... como:

 return [...this.getHouseTypes, newObject];

Pero eso me da un error:

 Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.

Alguien sabe a que se debe esto ?

¡Cualquier ayuda es bienvenida!

EDITAR: pero en el inspector vue muestra la nueva matriz con this.getHouseTypes y newObject en ella

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Suena más como que deberías hacer algo como esto:

 import { mapGetters } from 'vuex' export default { data() { return { houseTypes: [], } } // ... computed: { addHouseType(newType) { let houseTypes = this.getHouseTypes(); this.houseTypes = this.houseTypes.concat(houseTypes).push(newType); return this.houseTypes; }, // mix the getters into computed with object spread operator ...mapGetters([ 'getHouseTypes', // ... ]) } }

Tenga una variable data houseTypes , que es una matriz vacía al principio.

Mezcle sus getters , con su computed .

Tenga un computed que agregue valores a los tipos de casa locales y houseTypes el estado de la store .

Dependiendo de lo que esté haciendo, es posible que desee dividir la adición y la recuperación de la nueva array .

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!