wd-swiper-nav.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <template>
  2. <view v-if="showControls" class="wd-swiper-nav__btn">
  3. <view class="wd-swiper-nav__btn--prev" @click="handleNav('prev')" />
  4. <view class="wd-swiper-nav__btn--next" @click="handleNav('next')" />
  5. </view>
  6. <view
  7. v-if="total >= minShowNum"
  8. :style="customStyle"
  9. :class="`wd-swiper-nav wd-swiper-nav--${direction} wd-swiper-nav--${type} wd-swiper-nav--${indicatorPosition} ${customClass}`"
  10. >
  11. <block v-if="type === 'dots' || type === 'dots-bar'">
  12. <view
  13. v-for="(_, index) in total"
  14. :key="index"
  15. :class="`wd-swiper-nav__item--${type} ${current === index ? 'is-active' : ''} is-${direction}`"
  16. ></view>
  17. </block>
  18. <block v-if="type === 'fraction'">{{ current + 1 }}/{{ total }}</block>
  19. </view>
  20. </template>
  21. <script lang="ts" setup>
  22. import { swiperNavprops } from './types'
  23. defineProps(swiperNavprops)
  24. const emit = defineEmits(['change'])
  25. function handleNav(dir: 'prev' | 'next') {
  26. const source: string = 'nav'
  27. emit('change', { dir, source })
  28. }
  29. </script>
  30. <style lang="scss" scoped>
  31. @import './index.scss';
  32. </style>