2022-01-24 00:36:38 +08:00
|
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<n-card title="Swiper插件" class="shadow-sm rounded-16px">
|
|
|
|
|
<n-space :vertical="true">
|
|
|
|
|
<github-link link="https://github.com/nolimits4web/swiper" />
|
|
|
|
|
<web-site-link label="vue3版文档地址:" link="https://swiperjs.com/vue" />
|
|
|
|
|
<web-site-link label="插件demo地址:" link="https://swiperjs.com/demos" />
|
|
|
|
|
</n-space>
|
|
|
|
|
<n-space :vertical="true">
|
|
|
|
|
<div v-for="item in swiperExample" :key="item.id">
|
|
|
|
|
<h3 class="py-24px text-24px font-bold">{{ item.label }}</h3>
|
|
|
|
|
<swiper v-bind="item.options">
|
|
|
|
|
<swiper-slide v-for="i in 5" :key="i">
|
|
|
|
|
<div class="flex-center h-240px border-1px border-[#999] text-18px font-bold">Slide{{ i }}</div>
|
|
|
|
|
</swiper-slide>
|
|
|
|
|
</swiper>
|
|
|
|
|
</div>
|
|
|
|
|
</n-space>
|
|
|
|
|
</n-card>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import SwiperCore, { Navigation, Pagination } from 'swiper';
|
|
|
|
|
import { Swiper, SwiperSlide } from 'swiper/vue';
|
|
|
|
|
import type { SwiperOptions } from 'swiper';
|
|
|
|
|
|
|
|
|
|
type SwiperExampleOptions = Pick<
|
|
|
|
|
SwiperOptions,
|
2023-02-02 23:25:00 +08:00
|
|
|
|
'navigation' | 'pagination' | 'scrollbar' | 'slidesPerView' | 'slidesPerGroup' | 'spaceBetween' | 'direction' | 'loop'
|
2022-01-24 00:36:38 +08:00
|
|
|
|
>;
|
|
|
|
|
|
|
|
|
|
interface SwiperExample {
|
|
|
|
|
id: number;
|
|
|
|
|
label: string;
|
|
|
|
|
options: Partial<SwiperExampleOptions>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SwiperCore.use([Navigation, Pagination]);
|
|
|
|
|
|
|
|
|
|
const swiperExample: SwiperExample[] = [
|
|
|
|
|
{ id: 0, label: 'Default', options: {} },
|
|
|
|
|
{
|
|
|
|
|
id: 1,
|
|
|
|
|
label: 'Navigation',
|
|
|
|
|
options: {
|
2022-04-01 14:47:57 +08:00
|
|
|
|
navigation: true
|
|
|
|
|
}
|
2022-01-24 00:36:38 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 2,
|
|
|
|
|
label: 'Pagination',
|
|
|
|
|
options: {
|
2022-04-01 14:47:57 +08:00
|
|
|
|
pagination: true
|
|
|
|
|
}
|
2022-01-24 00:36:38 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 3,
|
|
|
|
|
label: 'Pagination dynamic',
|
|
|
|
|
options: {
|
2022-04-01 14:47:57 +08:00
|
|
|
|
pagination: { dynamicBullets: true }
|
|
|
|
|
}
|
2022-01-24 00:36:38 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 4,
|
|
|
|
|
label: 'Pagination progress',
|
|
|
|
|
options: {
|
|
|
|
|
navigation: true,
|
|
|
|
|
pagination: {
|
2022-04-01 14:47:57 +08:00
|
|
|
|
type: 'progressbar'
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-24 00:36:38 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 5,
|
|
|
|
|
label: 'Pagination fraction',
|
|
|
|
|
options: {
|
|
|
|
|
navigation: true,
|
|
|
|
|
pagination: {
|
2022-04-01 14:47:57 +08:00
|
|
|
|
type: 'fraction'
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-24 00:36:38 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 6,
|
|
|
|
|
label: 'Slides per view',
|
|
|
|
|
options: {
|
|
|
|
|
pagination: {
|
2022-04-01 14:47:57 +08:00
|
|
|
|
clickable: true
|
2022-01-24 00:36:38 +08:00
|
|
|
|
},
|
|
|
|
|
slidesPerView: 3,
|
2022-04-01 14:47:57 +08:00
|
|
|
|
spaceBetween: 30
|
|
|
|
|
}
|
2022-01-24 00:36:38 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 7,
|
|
|
|
|
label: 'Infinite loop',
|
|
|
|
|
options: {
|
|
|
|
|
navigation: true,
|
|
|
|
|
pagination: {
|
2022-04-01 14:47:57 +08:00
|
|
|
|
clickable: true
|
2022-01-24 00:36:38 +08:00
|
|
|
|
},
|
2022-04-01 14:47:57 +08:00
|
|
|
|
loop: true
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-24 00:36:38 +08:00
|
|
|
|
];
|
|
|
|
|
</script>
|
2022-05-28 12:30:17 +08:00
|
|
|
|
|
2022-01-24 00:36:38 +08:00
|
|
|
|
<style scoped></style>
|