幻灯片组
v-slide-group
组件用于显示伪装分页信息。 它在其核心中使用 v-item-group 并为诸如 v-tabs 和 v-chip-group 等组件提供一个基础。
用例
与 v-window 组件类似,v-slide-group
可以让项目占用尽可能多的空间。 允许用户通过提供的信息水平移动。
template script
<template>
<v-sheet
class="mx-auto"
max-width="700"
>
<v-slide-group multiple show-arrows>
<v-slide-item
v-for="n in 25"
:key="n"
v-slot:default="{ active, toggle }"
>
<v-btn
class="mx-2"
:input-value="active"
active-class="purple white--text"
depressed
rounded
@click="toggle"
>
Options {{ n }}
</v-btn>
</v-slide-item>
</v-slide-group>
</v-sheet>
</template>
<script>
export default {
data: () => ({
model: null,
}),
}
</script>
API
从下面选择您想要的组件,并查看可用的属性、插槽、事件和函数。
实战场
template script
<template>
<div>
<v-row justify="space-around">
<v-switch v-model="multiple" label="Multiple"></v-switch>
<v-switch v-model="mandatory" label="Mandatory"></v-switch>
<v-switch v-model="showArrows" label="Show arrows"></v-switch>
<v-switch v-model="prevIcon" label="Custom prev icon"></v-switch>
<v-switch v-model="nextIcon" label="Custom next icon"></v-switch>
<v-switch v-model="centerActive" label="Center active item"></v-switch>
</v-row>
<v-sheet
class="mx-auto"
elevation="8"
max-width="800"
>
<v-slide-group
v-model="model"
class="pa-4"
:prev-icon="prevIcon ? 'mdi-minus' : undefined"
:next-icon="nextIcon ? 'mdi-plus' : undefined"
:multiple="multiple"
:mandatory="mandatory"
:show-arrows="showArrows"
:center-active="centerActive"
>
<v-slide-item
v-for="n in 15"
:key="n"
v-slot:default="{ active, toggle }"
>
<v-card
:color="active ? 'primary' : 'grey lighten-1'"
class="ma-4"
height="200"
width="100"
@click="toggle"
>
<v-row
class="fill-height"
align="center"
justify="center"
>
<v-scale-transition>
<v-icon
v-if="active"
color="white"
size="48"
v-text="'mdi-close-circle-outline'"
></v-icon>
</v-scale-transition>
</v-row>
</v-card>
</v-slide-item>
</v-slide-group>
</v-sheet>
</div>
</template>
<script>
export default {
data: () => ({
model: null,
multiple: false,
mandatory: false,
showArrows: true,
prevIcon: false,
nextIcon: false,
centerActive: false,
}),
}
</script>
示例
下面是一些简单到复杂的例子。
自定义图标
您可以添加自定义分页图标,而不是箭头
template script
<template>
<v-sheet
class="mx-auto"
elevation="8"
max-width="800"
>
<v-slide-group
v-model="model"
class="pa-4"
prev-icon="mdi-minus"
next-icon="mdi-plus"
show-arrows
>
<v-slide-item
v-for="n in 15"
:key="n"
v-slot:default="{ active, toggle }"
>
<v-card
:color="active ? 'primary' : 'grey lighten-1'"
class="ma-4"
height="200"
width="100"
@click="toggle"
>
<v-row
class="fill-height"
align="center"
justify="center"
>
<v-scale-transition>
<v-icon
v-if="active"
color="white"
size="48"
v-text="'mdi-close-circle-outline'"
></v-icon>
</v-scale-transition>
</v-row>
</v-card>
</v-slide-item>
</v-slide-group>
</v-sheet>
</template>
<script>
export default {
data: () => ({
model: null,
}),
}
</script>
活动类
可以自定义活动类
template script
<template>
<v-sheet
class="mx-auto"
elevation="8"
max-width="800"
>
<v-slide-group
v-model="model"
class="pa-4"
active-class="success"
show-arrows
>
<v-slide-item
v-for="n in 15"
:key="n"
v-slot:default="{ active, toggle }"
>
<v-card
:color="active ? undefined : 'grey lighten-1'"
class="ma-4"
height="200"
width="100"
@click="toggle"
>
<v-row
class="fill-height"
align="center"
justify="center"
>
<v-scale-transition>
<v-icon
v-if="active"
color="white"
size="48"
v-text="'mdi-close-circle-outline'"
></v-icon>
</v-scale-transition>
</v-row>
</v-card>
</v-slide-item>
</v-slide-group>
</v-sheet>
</template>
<script>
export default {
data: () => ({
model: null,
}),
}
</script>
多选
您可以选择多个项目
template script
<template>
<v-sheet
class="mx-auto"
elevation="8"
max-width="800"
>
<v-slide-group
v-model="model"
class="pa-4"
multiple
show-arrows
>
<v-slide-item
v-for="n in 15"
:key="n"
v-slot:default="{ active, toggle }"
>
<v-card
:color="active ? 'primary' : 'grey lighten-1'"
class="ma-4"
height="200"
width="100"
@click="toggle"
>
<v-row
class="fill-height"
align="center"
justify="center"
>
<v-scale-transition>
<v-icon
v-if="active"
color="white"
size="48"
v-text="'mdi-close-circle-outline'"
></v-icon>
</v-scale-transition>
</v-row>
</v-card>
</v-slide-item>
</v-slide-group>
</v-sheet>
</template>
<script>
export default {
data: () => ({
model: [],
}),
}
</script>
Full-Zip Vuetify Jacket
The Vuetify Full-Zip Fleece is a great lightweight jacket to keep on hand during the chilly season.
ads by Vuetify
](https://store.vuetifyjs.com/product/full-zip-vuetify-jacket?ref=vuetifyjs.com)
必填项
必须选择至少 1 个项目
template script
<template>
<v-sheet
class="mx-auto"
elevation="8"
max-width="800"
>
<v-slide-group
v-model="model"
class="pa-4"
mandatory
show-arrows
>
<v-slide-item
v-for="n in 15"
:key="n"
v-slot:default="{ active, toggle }"
>
<v-card
:color="active ? 'primary' : 'grey lighten-1'"
class="ma-4"
height="200"
width="100"
@click="toggle"
>
<v-row
class="fill-height"
align="center"
justify="center"
>
<v-scale-transition>
<v-icon
v-if="active"
color="white"
size="48"
v-text="'mdi-close-circle-outline'"
></v-icon>
</v-scale-transition>
</v-row>
</v-card>
</v-slide-item>
</v-slide-group>
</v-sheet>
</template>
<script>
export default {
data: () => ({
model: null,
}),
}
</script>
伪轮播
自定义幻灯片组以在图纸上创造性地显示信息。 使用选择,我们可以为用户轻松显示辅助信息。
template script
<template>
<v-sheet
class="mx-auto"
elevation="8"
max-width="800"
>
<v-slide-group
v-model="model"
class="pa-4"
show-arrows
>
<v-slide-item
v-for="n in 15"
:key="n"
v-slot:default="{ active, toggle }"
>
<v-card
:color="active ? 'primary' : 'grey lighten-1'"
class="ma-4"
height="200"
width="100"
@click="toggle"
>
<v-row
class="fill-height"
align="center"
justify="center"
>
<v-scale-transition>
<v-icon
v-if="active"
color="white"
size="48"
v-text="'mdi-close-circle-outline'"
></v-icon>
</v-scale-transition>
</v-row>
</v-card>
</v-slide-item>
</v-slide-group>
<v-expand-transition>
<v-sheet
v-if="model != null"
color="grey lighten-4"
height="200"
tile
>
<v-row
class="fill-height"
align="center"
justify="center"
>
<h3 class="title">Selected {{ model }}</h3>
</v-row>
</v-sheet>
</v-expand-transition>
</v-sheet>
</template>
<script>
export default {
data: () => ({
model: null,
}),
}
</script>
居中活动项目
活动项目总是居中
template script
<template>
<v-sheet
class="mx-auto"
elevation="8"
max-width="800"
>
<v-slide-group
v-model="model"
class="pa-4"
center-active
show-arrows
>
<v-slide-item
v-for="n in 15"
:key="n"
v-slot:default="{ active, toggle }"
>
<v-card
:color="active ? 'primary' : 'grey lighten-1'"
class="ma-4"
height="200"
width="100"
@click="toggle"
>
<v-row
class="fill-height"
align="center"
justify="center"
>
<v-scale-transition>
<v-icon
v-if="active"
color="white"
size="48"
v-text="'mdi-close-circle-outline'"
></v-icon>
</v-scale-transition>
</v-row>
</v-card>
</v-slide-item>
</v-slide-group>
</v-sheet>
</template>
<script>
export default {
data: () => ({
model: null,
}),
}
</script>