I got this select code based on vue bootstrap:
<b-form-select v-model="selectedgroup" class="mb-3" @change="searchSubGroup()">
<option :value="null">Select a group</option>
<option v-for="group in groupItem" :value="group.id">
{{group.nome}}
</option>
</b-form-select>
When the searchSubGroup() method is called by @change event, the @change event pass a old value of selectedgroup. Example: If i click in option with value = 1 first, the method will call selectedgroup as null, then if i click again in another option with value = 2, the method will call selectedgroup as 1.
searchSubGroup(){
this.axios.get("http://chart.solutions/public/api/produto/subgroup/search/" + this.selectedgroup + "/").then(response => {
if (response.data.erro) {
//console.log("subgroup doesnt exist")
}else{
this.subGroupItem = response.data;
}
})
}