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

272
Views
Cómo subir la misma imagen en vue

Cuando subo una imagen por primera vez y luego la elimino de la entrada e intento cargarla nuevamente, la imagen no se carga.

La forma en que lo hago es que estoy usando el siguiente código en mi componente y, al cargar la imagen, estoy emitiendo una upload de eventos donde configuro el archivo en el campo.

Cuando hago clic en triggerFileVisibility , elimina el nombre de la imagen de la entrada, pero no me permite volver a cargar la misma imagen.

 <template> <div class="file-upload-wrapper"> <v-file-input v-bind="$props" ref="fileUpload" accept="image/png, image/jpeg, image/svg" :placeholder="fileName ? fileName : $t(labelType)" prepend-icon="mdi-camera" :disabled="!!fileName" :error-messages="getInvalidFeedback" v-on:change="uploadFiles" @focus="formFieldOnFocus" ></v-file-input> <v-icon v-if="!!fileName" class="close-icon" @click="triggerFileVisibility"> mdi-close </v-icon> </div> </template> <script> export default { name: 'FileUpload', props: { fileName: { default: '', type: String, }, labelType: { default: 'organization.uploadFile', type: String, }, invalidFeedback: { default: '', type: String, }, required: { type: Boolean, default: true, }, v: { type: Object, default: () => null, }, }, computed: { getUploadedImage() { console.log('getUploadedImage'); return this.fileName; }, getInvalidFeedback() { console.log('getInvalidFeedback') if (this.v && this.v.$error) { return this.invalidFeedback; } return ''; }, }, watch: { fileName: function(value, oldValue) { console.log(`fileName: new ${value} and OLD ${oldValue}`); this.$forceUpdate(); }, getFieldError: function(value) { if (value && this.v) { this.v.$touch(); } }, }, methods: { clear() { this.$refs.fileUpload.reset(); this.$emit('onchange', ''); }, uploadFiles(selectedFile) { console.log('UPLOAD'); this.$emit('upload', selectedFile); }, formFieldOnFocus(value) { console.log('formFieldOnFocus', this.$props); this.$emit('focus', value); if (this.v) { this.v.$reset(); } }, triggerFileVisibility() { console.log('triggerFileVisibility') this.$emit('upload', ''); }, }, }; </script> <style scoped> .file-upload-wrapper { position: relative; } .close-icon { position: absolute; top: 27%; right: 0; cursor: pointer; } </style>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

manera simple que debes usar

modelo v

en su código y después de eliminarlo borre este valor

about 4 years ago · Juan Pablo Isaza Report

0

Mi solución:

 <v-file-input v-bind="$props" ref="fileUpload" accept="image/png, image/jpeg, image/svg" :placeholder="fileName ? fileName : $t(labelType)" prepend-icon="mdi-camera" :disabled="!!fileName" :error-messages="getInvalidFeedback" @change="uploadFiles" @focus="formFieldOnFocus" ></v-file-input>

agregó: clave = "componentKey" y aumentó su valor al eliminar la imagen

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!