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

129
Views
Entrada addEventListener no funciona en el cambio

por favor ayúdame en esto. Estoy tratando de guardar la imagen de perfil, pero input.addeventlistener no archiva los cambios. estoy usando vue con rieles

Este es el gancho de montaje cuando estoy en un componente vue donde quiero activar el detector de eventos.

 mounted() { debugger this.previewUrl = this.placeholder; const input = this.$refs.inputSlot.querySelector('input[type="file"]') if (input) { input.addEventListener('change', event => { if(input.files[0]){ const fakeFilePath = event.currentTarget.value if (input.files[0].size > this.sizeLimit) { alert(this.$t('error.file_size', { max_size: this.maxSize })); input.value = ''; } else { this.fileName = input.files[0].name if (this.preview == 'image') { const reader = new FileReader(); reader.onload = event => { this.selectedFile = this.oldImage = this.previewUrl; this.previewUrl = event.target.result; this.choosenFile = fakeFilePath; }; reader.readAsDataURL(input.files[0]); } } } }) } }

Este es el campo de entrada

<input accept="image/jpeg,image/png,.jpeg" type="file" name="user[profile_picture]" id="user_profile_picture">

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

0

Simplemente puede agregar el atributo @change="save" a su entrada y después de cambiar el archivo, se activará el método de guardar

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!