swiper.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <script setup lang="ts">
  2. import "swiper/css";
  3. import "swiper/css/navigation";
  4. import "swiper/css/pagination";
  5. import SwiperCore from "swiper";
  6. import { Swiper, SwiperSlide } from "swiper/vue";
  7. import { Autoplay, Navigation, Pagination } from "swiper/modules";
  8. defineOptions({
  9. name: "Swiper"
  10. });
  11. SwiperCore.use([Autoplay, Navigation, Pagination]);
  12. const swiperExample: any[] = [
  13. { id: 0, label: "基础滑动", options: {} },
  14. {
  15. id: 1,
  16. label: "按钮切换",
  17. options: {
  18. navigation: true
  19. }
  20. },
  21. {
  22. id: 2,
  23. label: "分页器",
  24. options: {
  25. pagination: true
  26. }
  27. },
  28. {
  29. id: 3,
  30. label: "分页器 / 动态指示点",
  31. options: {
  32. pagination: { dynamicBullets: true }
  33. }
  34. },
  35. {
  36. id: 4,
  37. label: "分页器 / 进度条",
  38. options: {
  39. navigation: true,
  40. pagination: {
  41. type: "progressbar"
  42. }
  43. }
  44. },
  45. {
  46. id: 5,
  47. label: "分页器 / 分式",
  48. options: {
  49. navigation: true,
  50. pagination: {
  51. type: "fraction"
  52. }
  53. }
  54. },
  55. {
  56. id: 6,
  57. label: "一次显示多个Slides",
  58. options: {
  59. pagination: {
  60. clickable: true
  61. },
  62. slidesPerView: 3,
  63. spaceBetween: 30
  64. }
  65. },
  66. {
  67. id: 7,
  68. label: "无限循环",
  69. options: {
  70. autoplay: {
  71. delay: 2000,
  72. disableOnInteraction: false
  73. },
  74. navigation: true,
  75. pagination: {
  76. clickable: true
  77. },
  78. loop: true
  79. }
  80. }
  81. ];
  82. </script>
  83. <template>
  84. <el-card shadow="never">
  85. <template #header>
  86. <div class="font-medium">
  87. <el-link
  88. href="https://github.com/nolimits4web/swiper"
  89. target="_blank"
  90. style="margin: 0 5px 4px 0; font-size: 16px"
  91. >
  92. Swiper插件
  93. </el-link>
  94. </div>
  95. <el-link
  96. class="mt-2"
  97. href="https://github.com/pure-admin/vue-pure-admin/blob/main/src/views/components/swiper.vue"
  98. target="_blank"
  99. >
  100. 代码位置 src/views/components/swiper.vue
  101. </el-link>
  102. </template>
  103. <el-row :gutter="10">
  104. <el-col v-for="item in swiperExample" :key="item.id" :span="12">
  105. <h6 class="py-[16px]! text-base">{{ item.label }}</h6>
  106. <swiper v-bind="item.options">
  107. <swiper-slide v-for="i in 5" :key="i">
  108. <div
  109. class="flex justify-center items-center h-[240px] border border-[#999]"
  110. >
  111. Slide{{ i }}
  112. </div>
  113. </swiper-slide>
  114. </swiper>
  115. </el-col>
  116. </el-row>
  117. </el-card>
  118. </template>
  119. <style lang="scss" scoped>
  120. :deep(.el-card__body) {
  121. padding-top: 0;
  122. }
  123. </style>