My use case.
v-select
This is my code.
<v-select :items="categories" name="category" label="Select a category" v-model="category" v-validate="'required'"> </v-select>
But it gives me the output.
But I wants objects name property to be display in the v-select
We would do this in vanilla Vue.js
<li v-for="cat in categories" :key="cat.name">{{cat.name}}</li>
But here with vuetify we can't do this.
:items="categories.name"
Vuetify documentation
Can be an array of objects or array of strings. When using objects, will look for a text and value field. This can be changed using the item-text and item-value props.
What they actually mean by item-text
and item-value
How do I achieve this using item-text
According to Vue docs transforming selections, you use reduce to select to a single key. In your example, you'd be able to reduce to just returning the id(or name). See below: <v-select multiple :options="locations_ordered" v-model="state.modal.data.locations" label="name" :reduce="loc => loc.id"> </v-select>
There are 2 primary layout components in Vuetify, v-app and v-main . The v-app component is the root of your application and a direct replacement for the default Vue entrypoint, <div id="app"> . The v-main component is a semantic replacement for the main HTML element and the root of your application's content.
Your category has name
attribute, you can pass to item-text
:
<v-select :items="categories" v-model="category" name="category" v-validate="'required'" item-text="name" label="Select a category" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With