search

Home  >  Q&A  >  body text

Vuetify v-select attribute type check fails

<p>When I use v-select in Vuetify 3, I often encounter the following error: </p> <blockquote> <p>[Vue warning]: Invalid prop: Type check failed for prop 'title'. Expected String | Number | Boolean but got Object</p><p> In <VListItem key=0 title=`</p> </blockquote> <p>I'm not sure what the problem is. I'm getting an array of objects from a backend API as my JSON response. My goal is to display all the usernames in the dropdown, but when I select an item in the dropdown, I want to store the entire object in a variable. For example, if I select the "Desmond" username in the dropdown menu, I want the objects related to Desmond to be stored, i.e. <code>{"username": "Desmond","email": " desmond@test.com"}</code></p> <pre class="lang-js prettyprint-override"><code><v-select v-model="selectedItem" :items="items" name="username" item-text="username" label="Select Item" return-object ></v-select> </code></pre> <pre class="brush:php;toolbar:false;"><script> import axios from "axios"; export default { name: "Testing123", data() { return { items: [], selectedItem: null, }; }, created() { this.fetchItems(); }, methods: { fetchItems() { axios .get("http://localhost:5000/items", config) .then((response) => { this.items = response.data }) .catch((error) => { console.error(error); }); },</pre> <p>This is my<code>response.data</code></p> <pre class="brush:php;toolbar:false;">[ { "username": "Eric", "email": "eric@test.com", }, { "username": "Desmond", "email": "desmond@test.com", }, ]</pre></p>
P粉988025835P粉988025835438 days ago530

reply all(1)I'll reply

  • P粉707235568

    P粉7072355682023-09-05 00:16:39

    You are using :item-text, which is the property name in Vuetify v2, see here for details.

    In v3, this property has been renamed to :item-title.

    Change the name and it will work:

    <v-select
      item-title="username" 
      ...
    ></v-select>
    

    Examples can be seen in playground.

    reply
    0
  • Cancelreply