S
S
Sport-code2019-04-15 14:22:06
Vue.js
Sport-code, 2019-04-15 14:22:06

Why does v-select not work correctly?

Hello.
Please tell me why I click on edit in the data-table, a window appears with the correct data.
Category ID - the category ID is located,
and in the Category - the name
5cb4682bf3876755178048.png
As soon as I change the name of the category in the select, both the Category ID and the category
name appear in the Category
5cb468c423ccb978594212.png
My code:

<v-flex xs12 sm6 md4>
     <v-text-field v-model="editedItem.catId" label="Категория ID"></v-text-field>
</v-flex>

<v-flex xs12 sm6 md4>
     <v-select v-model="editedItem.catId" :items="getProducts" item-text='catName' item-value="editedItem.catId" label="Категория"></v-select>
</v-flex>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mr. Grump, 2019-04-15
@Sport-code

The problem is that you are not specifying the correct prop value item-value=""for v-select, to be more precise, you need to specify in this prop the name of the key for the value of each element of the select array, the value of which will be returned to the v-model
working example of your situation:
https://codepen.io/mrgrump/pen/ wZrVWq

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question