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

107
Views
How to select an option on Vue
<template>
 <select class="form-control mt-1" @change="selectUser">
  <option >select user</option>
  <option v-for="(user, index) in users" :key="index" {{user.first_name}}</option>
 </select>
</template>

<script>
selectUser(event){
 if(event.target.selectedIndex != 0){
   this.index = event.target.selectedIndex-1
   this.selectedUsers.push(this.users[this.index])
   this.users.splice(this.index, 1)
  }              
}
</script>

The idea of this script is that when you select an option it gets removed and added to another array of objects and it disappears from the select list. I want when this happened, the first option to get selected back again.

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

0

You can use v-model to get the selected item from <select>

<select v-model="selected">
        ......
</select>

and then use it this way:

<span>Selected: {{ selected }}</span>

about 4 years ago · Juan Pablo Isaza Report

0

The best way is to have :

  • a options and a selectedOption in the data.

  • A availableOptions as computed options, with options.filter(o => o !== this.selectedOption)

  • Bind the select with a v-model=selectedOption

  • bind the with the avaiableOptions

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!