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

255
Views
How to get selected/removed value in <v-select> multiple vuejs

I have this v-select :

<v-select
    multiple
    v-model="group.structures"
    :options="filter"
    label="name"
    @input="changed"
></v-select>

When I get the attribute of my function "changed", I got an array with all selected values when I add or remove an item from my v-select.

changed(value) {
    console.log(value); // Return an array with all items in (group.structures).
}

I don't want to get all the array but only the selected/removed value. Is there any way to get the selected value?

Thanks.

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

0

One of the ways to achieve what you want is store the previous value in variable then compare the new value with it

data() {
  return {
    previousSelectedStructures: [];
    // ...
  }
}
changed(value) {
    let added = value.filter(
      (val) => !this.previousSelectedStructures.includes(val)
    );
    let removed = this.previousSelectedStructures.filter(
      (val) => !value.includes(val)
    );

    // Do some stuff

    console.log(value);
    this.previousSelectedStructures = value;
}
about 4 years ago · Juan Pablo Isaza Report

0

Wow! It works! Thank you!

For those who have the same request, don't forget to fill your previousSelectedStructures up with the existing content :

created(){
        this.previousSelectedStructures = this.group.structures;
    },
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!