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

336
Views
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 answers
Answer question

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 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!