You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.9 KiB

2 years ago
  1. <template>
  2. <section
  3. :class="['tw-relative tw-mt-[48px] xl:tw-max-w-[1246px] xl:tw-mx-auto']"
  4. >
  5. <div
  6. class="swiper-container perColumn xl:tw-max-w-[1106px] xl:tw-mx-auto xl:tw-px-[22px]"
  7. ref="perColumn"
  8. @mouseenter="enter"
  9. @mouseleave="leave"
  10. >
  11. <div :class="['swiper-wrapper']">
  12. <div
  13. v-for="(item, index) in list"
  14. :key="index"
  15. :class="['swiper-slide']"
  16. >
  17. <div class="tw-rounded-[24px]">
  18. <lazyImg
  19. :src="item.image"
  20. :customClass="'swiper-lazy tw-rounded-[24px]'"
  21. ></lazyImg>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </section>
  27. </template>
  28. <script>
  29. import Swiper from "swiper/bundle";
  30. import lazyImg from "@/components/img/img.vue";
  31. export default {
  32. components: {
  33. Swiper,
  34. lazyImg,
  35. },
  36. props: {
  37. list: {
  38. type: Array,
  39. },
  40. },
  41. data() {
  42. return {
  43. perColumn: null,
  44. };
  45. },
  46. mounted() {
  47. let vm = this;
  48. vm.$nextTick(function () {
  49. vm.perColumn = new Swiper(".swiper-container.perColumn", {
  50. direction: "horizontal",
  51. initialSlide: 0,
  52. slidesPerView: "auto",
  53. observer: true, //修改swiper自己或子元素时,自动初始化swiper
  54. observeParents: true, //修改swiper的父元素时,自动初始化swiper
  55. spaceBetween: 32,
  56. lazy: {
  57. loadPrevNext: true,
  58. loadOnTransitionStart: true,
  59. loadPrevNextAmount: 2,
  60. },
  61. breakpoints: {
  62. 1366: {
  63. slidesPerView: 3,
  64. spaceBetween: 24,
  65. grabCursor: true,
  66. },
  67. },
  68. });
  69. });
  70. },
  71. methods: {},
  72. };
  73. </script>
  74. <style lang="scss" scoped>
  75. .swiper-container {
  76. width: 100% !important;
  77. }
  78. </style>