Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

276
Visualizações
Vue3 - Getting next item from object - value not updating

I am trying to let my users go through an object that contains different items.

Example of records object:

0: {id: 1, pipeline_id: 1, raw: '1', completion: null, processed: 0, …}
1: {id: 2, pipeline_id: 1, raw: '2', completion: null, processed: 0, …}
2: {id: 3, pipeline_id: 1, raw: '3', completion: null, processed: 0, …}
3: {id: 4, pipeline_id: 1, raw: '4', completion: null, processed: 0, …}
4: {id: 5, pipeline_id: 1, raw: '5', completion: null, processed: 0, …}

I am using Vue3 and Collect.js like below:

const props = defineProps({
    records: {
        type: Object,
    },
});

let currentRecord = collect(props.records).first();

const nextRecord = () => {
    // Set "currentRecord" to the next item in the "records" array.
    currentRecord = collect(props.records).slice(props.records.indexOf(currentRecord) + 1).first();

    console.log(currentRecord)
}

The users can shuffle through the array using the nextRecord method:

<textarea v-model="currentRecord.raw"></textarea>

<a @class="nextRecord">Skip Record</a>

The above code successfully changes the currentRecord in the console.log, but not in the <textarea>.

What am I doing wrong?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Define currentRecordIndex initialized with 0 and increment it using the click event handler and use computed property to return the currentRecord :

import {computed,ref} from 'vue'

const props = defineProps({
    records: {
        type: Object,
    },
});
let currentRecordIndex =ref(0)
let currentRecord = computed(()=>collect(props.records).slice(currentRecordIndex.value).first());

const nextRecord = () => {
   currentRecordIndex.value++;
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda