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

341
Views
Vue remaining items in data value if it is array

I have Vue application which has a array of errors in data object. Problem is that I can not set errors array to empty []. I try to set it in the begining of validation function but previous items still remain there. This is the code:

<div v-if="uploadErrors && uploadErrors.length" class="has-text-danger">
     <div v-for="(error, index) in uploadErrors" :key="index" class="is-size-7">{{error}}</div>
</div>

data() {
    return {
        uploadErrors: [],
    }
},


validateUploadFiles(files) {

    this.uploadErrors = [];
    console.log(this.uploadErrors); // uploadErrors still contains previous items

    files.forEach( file => {
        const foundFormat = this.allowedFormats.find( format => format.mimeType === file.type );
        const isBigger = this.maxSize * 2 ** 20 < file.size;

        if( isBigger ) this.uploadErrors.push( this.$t("campaign.upload.size_limit") );
        if( !foundFormat ) this.uploadErrors.push( this.$t("campaign.upload.format") + ' ' + file.name );
    });

    console.log(this.uploadErrors);  // uploadErrors still contains previous items
}

What is wrong with that? I dont understand.

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