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

329
Vistas
Vue3 won't trigger watch when using v-model:prop="data"

I'm creating a child component for my filters which should be updated when the user changes some input values... The problem is that when I emit the new data into the parent component the watch won't trigger! Please review my code to see where I went wrong...

Parent Component

Defining the component
<FiltersComponent v-model:filters="filters" />
Defining the watch expression
watch(filters, (value) => {
  getAccounts(value);
});

Child Component

const emits = defineEmits(['update:filters']);
const props = defineProps({
  filters: {
    type: Object,
    default: () => ({
      ...
    }),
    required: true,
  },
});

function updateFilters(newValue, property) {
  console.log('updateFilters', newValue, property);
  emits('update:filters', { ...props.filters, [property]: newValue });
}

note: the console.log prints the newValue and property correctly but the watch never happens!

PS: I used the v-on:update:filters="getAccounts(filters)" inside parent component too. but the filters data is not updated inside function call...

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to set deep to true when watching an array or object so that Vue knows that it should watch the nested data for changes. Try using this:

    watch(filters, (value) => {
      getAccounts(value);
    },
      {
       deep: true
      }
    );

For reference please review the vue 3 documentation: https://v3.vuejs.org/guide/migration/watch.html#_3-x-syntax

about 4 years ago · Juan Pablo Isaza 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