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

307
Vistas
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 Respuestas
Responde la pregunta

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