Customizing item-text in v-select

前端 未结 5 652
情书的邮戳
情书的邮戳 2020-12-23 16:21

Please tell me if we can customize item-text for v-select ?

I want customize each item in v-select, something like this :<

5条回答
  •  余生分开走
    2020-12-23 16:57

    Yes you can, using scoped slot as described in the doc and provide a template.

    For v-select you have two scoped slot :

    • selection : to describe how v-select should render items when selected
    • item : to describe how v-select should render items when opened

    It looks like this :

     // Don't forget your props
      
      
    
    

    CodePen with a complex example

    Vuetify Doc about Scoped Slot in V-Select


    Edit for Vuetify 1.1.0+ : Those slots are also available with new components v-autocomplete and v-combobox as they inherit from v-select.


    Edit for Vue 2.6+, replace :

    • slot="selection" slot-scope="data" by v-slot:selection="data"
    • slot="item" slot-scope="data" by v-slot:item="data"

提交回复
热议问题