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

166
Vistas
Vue input upload doesn't work after cancel

So I have this v-btn element in my vue project that I use to upload a file.The uploaded file's name is saved in a string pickeruploadedref.I added a div element with v-if=pickeruploadref!='' that displays the name of the uploaded file saved in pickeruploadedref and a button that on click executes the canceluploadref method which simply turns pickeruploadedref back to an empty string.This is my code in template

 <!-- 1. Create the button that will be clicked to select a file -->
        <v-btn 
            color="primary" 
            rounded 
            dark 
            :loading="isSelectingref" 
            @click="handleFileImportref"
        >
            Upload File
        </v-btn>

        <!-- Create a File Input that will be hidden but triggered with JavaScript -->
        <input 
            ref="uploader1" 
            class="d-none" 
            type="file" 
            @change="onFileChangedref"
        >
             <div v-if="pickeruploadref!=''">
              {{this.pickeruploadref}}
                  <v-btn
      class="ma-2"
      outlined
      small
      fab
      color="red"
      @click="canceluploadref()"
    >
      <v-icon>mdi-close</v-icon>
    </v-btn>
            </div>

in script

export default {
  data() {
    return {
      isSelectingref: false,    
      pickerref: "",
      pickeruploadref:"",
    }
  },
methods: {

    canceluploadref(){
       console.log(this.pickeruploadref)

      this.pickeruploadref=''
      console.log(this.pickeruploadref)
    },
     handleFileImportref() {
                this.isSelectingref = true;

                // After obtaining the focus when closing the FilePicker, return the button state to normal
                window.addEventListener('focus', () => {
                    this.isSelectingref = false
                }, { once: true });
                
                // Trigger click on the FileInput
                this.$refs.uploader1.click();
            },
                
            onFileChangedref(e) {
              if (e.target.files[0]!=null)
              {
                let name= e.target.files[0].name;
                 name=name.replace('.json','')
                  this.pickeruploadref=name
                        console.log(this.pickeruploadref)

              
              }

the first time i use the button everything works fine the file name is saved in the pickeruploadedref string and the button to make pickeruploadedref an empty string is shown and when I click on it pickeruploadedref is empty again but when I reuse the upload button,pickeruploadref stays as an empty string and the handlefileimportref is not getting executed for some reason.

about 4 years ago · Juan Pablo Isaza
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