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

310
Views
Vue 2 watch fails for mixin data property, but works if the component has the data property

I am trying to move some functionality to a vue mixin from the component, to be able to use it in multiple components.

This (simplified version of the code) works:

export default {
  data() {
    return {
      file: {},
      audioPlayer: {
        sourceFile: null,
      },
    };
  },
  watch: {
    'audioPlayer.SourceFile': function (nextFile) {
       console.log('new sourceFile');
       this.$data.file = nextFile;
    },
  }
}

But if I move the audioPlayer data object to a mixin, the watch does no longer fire.

Is this expected behavior?

N.b. I resolved this by directly making the 'file' data property into a computed value, which works in this particular case, but the behavior is still strange.

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

0

You need a lowercase s. sourceFile not SourceFile

watch: {
    'audioPlayer.sourceFile': function (nextFile) {
       console.log('new sourceFile');
       this.$data.file = nextFile;
    },
  }
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!