纸片组
v-chip-group
通过提供可添加的功能来添加 v-chip
组件。它用于使用纸片创建选择组。
用例
纸片组使用户可以方便地为更复杂的实现选择过滤选项。默认情况下,v-chip-group
将向右溢出,但可以更改为 column 模式。
API
从下面选择您想要的组件,并查看可用的属性、插槽、事件和函数。
示例
下面是一些简单到复杂的例子。
列
带有 column
属性的纸片组可以包装其纸片。
template script
<template>
<v-row justify="space-around">
<v-col cols="12" sm="6" md="4" lg="3">
<v-sheet elevation="10" class="pa-4">
<v-chip-group
column
active-class="primary--text"
>
<v-chip v-for="tag in tags" :key="tag">
{{ tag }}
</v-chip>
</v-chip-group>
</v-sheet>
</v-col>
</v-row>
</template>
<script>
export default {
data: () => ({
tags: [
'Work',
'Home Improvement',
'Vacation',
'Food',
'Drawers',
'Shopping',
'Art',
'Tech',
'Creative Writing',
],
}),
}
</script>
必填项
具有 mandatory
属性的纸片组必须始终选择一个值。
template script
<template>
<v-row justify="space-around">
<v-col cols="12" sm="6" md="4">
<v-sheet elevation="10" class="py-4 px-1">
<v-chip-group
mandatory
active-class="primary--text"
>
<v-chip v-for="tag in tags" :key="tag">
{{ tag }}
</v-chip>
</v-chip-group>
</v-sheet>
</v-col>
</v-row>
</template>
<script>
export default {
data: () => ({
tags: [
'Work',
'Home Improvement',
'Vacation',
'Food',
'Drawers',
'Shopping',
'Art',
'Tech',
'Creative Writing',
],
}),
}
</script>
多选
具有 multiple
属性的纸片组可以选择许多值。
template script
<template>
<v-row justify="space-around">
<v-col cols="12" sm="6" md="4">
<v-sheet elevation="10" class="py-4 px-1">
<v-chip-group
multiple
active-class="primary--text"
>
<v-chip v-for="tag in tags" :key="tag">
{{ tag }}
</v-chip>
</v-chip-group>
</v-sheet>
</v-col>
</v-row>
</template>
<script>
export default {
data: () => ({
tags: [
'Work',
'Home Improvement',
'Vacation',
'Food',
'Drawers',
'Shopping',
'Art',
'Tech',
'Creative Writing',
],
}),
}
</script>
Dark Vuetify Stickers
Stick them to your car, laptop or favorite mug. They are made from a durable vinyl with a laminate that is weather-proof against rain, sun, wind and snow, and even dishwasher safe.
ads by Vuetify
](https://vuetifyjs.com/zh-Hans/components/chip-groups/ “url”: “https:/store.vuetifyjs.com/product/black-vuetify-vinyl-stickers”?ref=vuetifyjs.com)
牙刷卡片
纸片组允许创建自定义接口,这些接口执行与项组或单选控件相同的操作,但在风格上有所不同。
template script
<template>
<v-card
class="mx-auto"
max-width="400"
>
<v-card-title>
<h2 class="display-1">Toothbrush</h2>
<v-spacer></v-spacer>
<span class="title">$4.99</span>
</v-card-title>
<v-card-text>
Our company takes pride in making handmade brushes.
Our toothbrushes are available in 4 different bristel types, from extra soft to hard.
</v-card-text>
<v-divider class="mx-4"></v-divider>
<v-card-text>
<span class="subheading">Select type</span>
<v-chip-group
v-model="selection"
active-class="deep-purple--text text--accent-4"
mandatory
>
<v-chip>Extra Soft</v-chip>
<v-chip>Soft</v-chip>
<v-chip>Medium</v-chip>
<v-chip>Hard</v-chip>
</v-chip-group>
</v-card-text>
<v-card-actions>
<v-btn
block
class="white--text"
color="deep-purple accent-4"
>
Add to Cart
</v-btn>
</v-card-actions>
</v-card>
</template>
<script>
export default {
data: () => ({
selection: 2,
}),
}
</script>
衬衫产品卡片
v-chip
组件可以具有用于其模型的显式值。这将传递给 v-chip-group
组件,在不希望使用纸片索引作为其值时非常有用。
template script
<template>
<v-card
class="mx-auto"
max-width="400"
>
<v-card-title>
<h2 class="display-1">Shirt Blouse</h2>
<v-spacer></v-spacer>
<span class="title">$44.50</span>
</v-card-title>
<v-card-text>
Our blouses are available in 8 colors. You can custom order a built-in arch support for any of the models.
</v-card-text>
<v-divider class="mx-4"></v-divider>
<v-card-text>
<span class="subheading">Select size</span>
<v-chip-group
v-model="selection"
active-class="deep-purple--text text--accent-4"
mandatory
>
<v-chip v-for="size in sizes" :key="size" :value="size">
{{ size }}
</v-chip>
</v-chip-group>
</v-card-text>
<v-card-actions>
<v-btn
block
class="white--text"
color="deep-purple accent-4"
>
Add to Cart
</v-btn>
</v-card-actions>
</v-card>
</template>
<script>
export default {
data: () => ({
selection: '08',
sizes: [
'04', '06', '08', '10', '12', '14',
],
}),
}
</script>
过滤结果
使用 filter 属性轻松创建纸片组,以提供更多反馈。 这创建了一种替代的视觉风格,可以与用户交流选择了纸片的情况。
template script
<template>
<v-card
class="mx-auto"
max-width="400"
>
<v-toolbar
flat
color="deep-purple accent-4"
dark
>
<v-btn icon>
<v-icon>mdi-close</v-icon>
</v-btn>
<v-toolbar-title>Filter results</v-toolbar-title>
</v-toolbar>
<v-card-text>
<h2 class="title mb-2">Choose amenities</h2>
<v-chip-group
v-model="amenities"
column
multiple
>
<v-chip filter outlined>Elevator</v-chip>
<v-chip filter outlined>Washer / Dryer</v-chip>
<v-chip filter outlined>Fireplace</v-chip>
<v-chip filter outlined>Wheelchair access</v-chip>
<v-chip filter outlined>Dogs ok</v-chip>
<v-chip filter outlined>Cats ok</v-chip>
</v-chip-group>
</v-card-text>
<v-card-text>
<h2 class="title mb-2">Choose neighborhoods</h2>
<v-chip-group
v-model="neighborhoods"
column
multiple
>
<v-chip filter outlined>Snowy Rock Place</v-chip>
<v-chip filter outlined>Honeylane Circle</v-chip>
<v-chip filter outlined>Donna Drive</v-chip>
<v-chip filter outlined>Elaine Street</v-chip>
<v-chip filter outlined>Court Street</v-chip>
<v-chip filter outlined>Kennedy Park</v-chip>
</v-chip-group>
</v-card-text>
</v-card>
</template>
<script>
export default {
data: () => ({
amenities: [1, 4],
neighborhoods: [1],
}),
}
</script>