index.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <view class='swiper'>
  3. <swiper :autoplay="autoplay" :circular="circular" :interval="interval" :duration="duration" @change="swiperChange">
  4. <block v-for="(item,index) in imgUrls" :key="index">
  5. <swiper-item>
  6. <navigator :url="item.link" style='width:100%;height:100%;' hover-class='none'><image :src="item.img" class="slide-image"/></navigator>
  7. </swiper-item>
  8. </block>
  9. </swiper>
  10. <view class="dots acea-row">
  11. <view class="dot" :class="index == currentSwiper ? 'active' : ''" v-for="(item,index) in imgUrls" :key="index"></view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. props: {
  18. imgUrls: {
  19. type: Array,
  20. default: function(){
  21. return [];
  22. }
  23. }
  24. },
  25. data() {
  26. return {
  27. circular: true,
  28. autoplay: true,
  29. interval: 3000,
  30. duration: 500,
  31. currentSwiper: 0
  32. };
  33. },
  34. methods: {
  35. swiperChange: function (e) {
  36. this.currentSwiper = e.detail.current
  37. }
  38. }
  39. }
  40. </script>
  41. <style scoped lang="scss">
  42. .swiper{width:100%;height:282rpx;position:relative;}
  43. .swiper swiper{width:100%;height:100%;position:relative;}
  44. .swiper swiper .slide-image{width:100%;height:100%;}
  45. .swiper .dots{position:absolute;right:40rpx;bottom:20rpx;}
  46. .swiper .dots .dot{width:12rpx;height:12rpx;border:2rpx solid #fff;border-radius:50%;margin-right:15rpx;}
  47. .swiper .dots .dot.active{border-color:#e93323;background-color:#e93323;}
  48. </style>