I have difficulty using vue-select (v-select) when editing data. Currently v-select displays the ID, the data that should appear is the text or label.
const detailPresensi = {
detail_data: [{
"id": 3,
"project_id": 1,
"duration_minute": 300,
"detail": "Text 1"
}, {
"id": 4,
"project_id": 2,
"duration_minute": 203,
"detail": "Text 2"
}]
}
let options = {
"1": "AAA",
"2": "BBB",
"3": "CCC",
};
here is the script: jsfiddle
My expectations: if the data array in detail_data has project_id: 1 then the data displayed is the name "AAA",
Thanks.
Edited-
I believe you need to fix a few things first-
opsi
property is missing from the data.Now, about your issue that always id is displaying in the selected option, the reason behind this is using reduce prop. It is mentioned in the documentation's section, Caveats with reduce-
So, either remove reduce or if wants to continue with the
reduce
, you need to do the following-v-select
in the loop, which means eachv-select
should have its ownv-model
binding, so create aselected
variable for each data item and usev-model="item.selected"
.opsi
array, put this in the item'sselected
variable by default, like this-Read more about-
1. Using v-select in the loop.
2. Display selected text using slots.