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

248
Visualizações
(Vue.js) Values not updating themselves correctly

I have this weird issue i can't fix. The testArray is supposed to change its value from 'This is a test' into the items array from ItemList, and it does. However, it updates itself in a weird way, almost like its one update late - when i change the emit to ('response', items), it doesn't work. But, when i swap 'items' to 'test', it shows the array.

Any help would be much appreciated!

App.vue

<script setup>
  import ItemList from "./components/ItemList.vue";
  import {ref} from "vue";

  const testArray = ref('This is a test')
</script>
<template>
  <ItemList @response="(msg) => testArray = msg" />
  <ul>
    <li v-for="item in testArray" :key="item.id">
      {{item.name}}
    </li>
  </ul>
</template>

ItemList.vue

<script setup>
  import {ref} from "vue";
  const items = ref([
    {id: 1, name: 'SomeRandomName'},
    {id: 2, name: 'SomeRandomName'},
    {id: 3, name: 'SomeRandomName'},
  ])
  const test = ref(['Something'])
  const emit = defineEmits(['response'])
  emit('response', items)
</script>

<template>

</template>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Did you try with:

emit('response', items.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