0
votes

i am trying to assign items to my v-select dropdown but i keep getting the message no data available, i have an array of objects. i am using the template slot but not sure what I'm doing wrong.

I have made a codepen for demonstration: https://codepen.io/anon/pen/LKmZKZ?editors=1011

  <div id="app">
  <v-app id="inspire">
   <v-container>
     <v-layout>
      <v-flex xs4>
      <v-select :items="items" label="people">
        <template slot="selection-item" slot-scope="item">
          <v-icon :color="item.icon_color">{{item.icon}}</v-icon>
          {{item.name}}
          </template>
         </v-select>
      </v-flex>
     </v-layout>
   </v-container>
  </v-app>
 </div>


new Vue({
  el: '#app',
  data() {
   return {
  items: [
    {name: 'Karen', icon : 'search', icon_color: 'red'},
    {name: 'Gordon', icon : 'person', icon_color: 'yellow'},
    {name: 'Craig', icon : 'opacity', icon_color: 'blue'},
    {name: 'Chris', icon : 'pets', icon_color: 'orange'},
     ]
   }
  }
 })

Thank you in advance guys.

3
you have a typo : v-select :ietms - Bernard Pagoaga
@SirDad i fixed it but now it just says [object object] in the dropdown. - Somethingwhatever
@BernardPagoaga i fixed it but now it just says [object object] in the dropdown. - Somethingwhatever
figured it out : v-slot:item="{item, index}" - Somethingwhatever

3 Answers

2
votes

v-select expects an array of strings as the value but you are binding an array filled with objects that's why you are seeing [object object]so you gotta add item-text prop:

<v-select
  :items="items"
   name="item"
   label="Select a item"
   item-text="name"
></v-select>
0
votes

u are writing

<v-select :ietms="items" label="people">

should be

<v-select :items="items" label="people">

i never used vuetify but i found in documentacion about this, then i forked your pen: https://codepen.io/christiancazu/pen/mZLWpL

0
votes

You are missing item text item-text="name", thats why it says [object object] in the dropdown

<div id="app">
  <v-app id="inspire">
   <v-container>
     <v-layout>
      <v-flex xs4>
      <v-select :items="items" item-text="name" label="people">
        <template slot="selection-item" slot-scope="item">
          <v-icon :color="item.icon_color">{{item.icon}}</v-icon>
          {{item.name}}
          </template>
         </v-select>
      </v-flex>
     </v-layout>
   </v-container>
  </v-app>
 </div>

This should work