[英]How to use icons in vuetify v-select?
I have the following v-select that is filled using an array and items prop as shown:我有以下使用数组和 items 道具填充的 v-select,如图所示:
<v-select v-model="myModel"
:items="users"
chips
:readonly="!item.Active"
label="Required users to finalize"
item-text="NAME"
item-value="ID"
multiple
filled
return-object
>
</v-select>
My array has the following:我的数组有以下内容:
[{NAME: "NAME1", ID: "001", IS_ACTIVE: true},{NAME: "NAME2", ID: "002", IS_ACTIVE: false} ]
I would like my v-select chips to have a checkmark next to the selected users if they are active.如果他们处于活动状态,我希望我的 v-select 芯片在所选用户旁边有一个复选标记。 My v-chip should basically look like this:我的 v-chip 基本上应该是这样的:
<v-chip
class="ma-2"
color="teal"
text-color="white"
>
<v-avatar left>
<v-icon>mdi-checkbox-marked-circle</v-icon>
</v-avatar>
</v-chip>
How can I use a v-chip
with an icon in this v-select?如何在此 v-select 中使用带有图标的v-chip
?
Try this :试试这个:
new Vue({ el: '#app', vuetify: new Vuetify(), data: () => ({ users: [{NAME: "NAME1", ID: "001", IS_ACTIVE: true},{NAME: "NAME2", ID: "002", IS_ACTIVE: false}], }), })
<script src="https://unpkg.com/vue@2.x/dist/vue.js"></script> <script src="https://unpkg.com/vuetify@2.6.6/dist/vuetify.min.js"></script> <link rel="stylesheet" href="https://unpkg.com/vuetify@2.6.6/dist/vuetify.min.css"/> <link rel="stylesheet" href="https://unpkg.com/@mdi/font@6.x/css/materialdesignicons.min.css"/> <div id="app"> <v-app id="inspire"> <v-container fluid> <v-select :items="users" label="Required users to finalize" item-text="NAME" item-value="ID" multiple filled chips return-object > <template #selection="{ item }"> <v-chip v-if="item.IS_ACTIVE" class="ma-2" color="teal" text-color="white" > <v-avatar left> <v-icon>mdi-checkbox-marked-circle</v-icon> </v-avatar> {{ item.NAME }} </v-chip> </template> </v-select> </v-container> </v-app> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.