Vue TDesign Select 选择器自定义 Tag 标签
TDesign Vue About 1,102 words自定义 Tag
使用#valueDisplay="{ value }"
这个slot
插槽(valueDisplay
的值固定为value
)。
这样可以根据option
中的item
,自定义每一个Tag
标签。
<t-select
:max="8"
v-model="list"
placeholder="请选择"
multiple
clearable
@popup-visible-change="popupVisibleChange"
:tagProps="{closable: true}"
>
<template #valueDisplay="{ value }">
<t-tag v-for="item in value" closable :color="item?.disabled ? 'red' : ''">{{item?.label}}</t-tag>
</template>
<t-option label="全选" :check-all="true" />
<t-option v-for="item in prizes" :key="item.value" :value="item.value" :label="item.label" :disabled="item.disabled"></t-option>
</t-select>
禁用 option item
如果禁用了option
中的某几个item
,此时这个item
对应的Tag
标签的closeable
等于false
。
如果希望Tag
始终保持可以关闭,:tagProps="{closable: true}"
加上这条属性即可。
<t-select
:max="8"
v-model="list"
placeholder="请选择"
multiple
clearable
@popup-visible-change="popupVisibleChange"
:tagProps="{closable: true}"
>
<t-option label="全选" :check-all="true" />
<t-option v-for="item in prizes" :key="item.value" :value="item.value" :label="item.label" :disabled="item.disabled"></t-option>
</t-select>
Views: 28 · Posted: 2025-08-21
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓

Loading...