Swiper中文论坛

标题: 移动端整屏滑动很卡,一点都不丝滑怎么办 [打印本页]

作者: bujiatang    时间: 2023-9-7 14:43
标题: 移动端整屏滑动很卡,一点都不丝滑怎么办
  1. <script setup lang="ts">

  2. let Compoennt1 = {},
  3.   Compoennt2 = {},
  4.   Compoennt3 = {},
  5.   Compoennt4 = {},
  6.   Compoennt5 = {};

  7. const onSlideChange = () => {
  8.   const activeIndex = mySwiper.value.activeIndex;
  9.   currIndex.value = activeIndex;

  10.   if (activeIndex == 1) {
  11.     Compoennt1 = defineAsyncComponent(() => import("../components/Compoennt1.vue"), true);
  12.   }
  13.   if (activeIndex == 2) {
  14.     Compoennt2 = defineAsyncComponent(() => import("../components/Compoennt2.vue"));
  15.   }
  16.   if (activeIndex == 3) {
  17.     Compoennt3 = defineAsyncComponent(() => import("../components/Compoennt3.vue"));
  18.   }
  19.   if (activeIndex == 4) {
  20.     Compoennt4 = defineAsyncComponent(() => import("../components/Compoennt4.vue"));
  21.   }
  22.   if (activeIndex == 5) {
  23.     Compoennt5 = defineAsyncComponent(() => import("../components/Compoennt5.vue"));
  24.   }
  25. };

  26. </script>

  27. <template>
  28.   <swiper
  29.       @swiper="onSwiper"
  30.       autoHieght
  31.       @slideChange="onSlideChange"
  32.       class="home-swiper"
  33.       direction="vertical"
  34.       :speed="500"
  35.       :touchRatio="2"
  36.       :resistanceRatio="0.9"
  37.     >
  38.       <swiper-slide>
  39.          <Component1 />
  40.       </swiper-slide>
  41.       <swiper-slide >
  42.         <Component2 />
  43.       </swiper-slide>
  44.       <swiper-slide >
  45.          <Component3 />
  46.       </swiper-slide>
  47.       <swiper-slide >
  48.          <Component4 />
  49.       </swiper-slide>
  50.       <swiper-slide>
  51.          <Compoennt5 />
  52.       </swiper-slide>
  53.     </swiper>


  54. </template>


复制代码







欢迎光临 Swiper中文论坛 (http://bbs.swiper.com.cn/) Powered by Discuz! X3.2