swiper-image.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <view>
  3. <view class="swiper-view">
  4. <swiper class="swiper" :indicator-dots="indicatorDots" :indicator-color="indicatorColor"
  5. :indicator-active-color="indicatorActiveColor" :autoplay="autoplay" :interval="interval"
  6. :duration="duration" :circular="circular" :vertical="vertical" @change="changeEvent"
  7. :style="'height:'+height">
  8. <swiper-item v-for="(item,index) in resdata" :key="index" @tap="tipEvent(item)"
  9. :style="'height:'+height">
  10. <image mode="scaleToFill" :src="item.image" :style="'height:'+height" lazy-load></image>
  11. </swiper-item>
  12. </swiper>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. props: {
  19. resdata: Array,
  20. indicatorDots: { //是否显示面板指示点
  21. type: Boolean,
  22. default: true
  23. },
  24. indicatorColor: { //指示点颜色
  25. type: String,
  26. default: 'rgba(0, 0, 0, .3)'
  27. },
  28. indicatorActiveColor: { //当前选中的指示点颜色
  29. type: String,
  30. default: "#FFFFFF"
  31. },
  32. autoplay: { //是否自动切换
  33. type: Boolean,
  34. default: true
  35. },
  36. interval: { //自动切换时间间隔
  37. type: Number,
  38. default: 5000
  39. },
  40. duration: { //滑动动画时长
  41. type: Number,
  42. default: 500
  43. },
  44. circular: { //是否循环衔接
  45. type: Boolean,
  46. default: true
  47. },
  48. vertical: { //是否循环衔接
  49. type: Boolean,
  50. default: false
  51. },
  52. height: { //轮播高度
  53. type: String,
  54. default: "280upx"
  55. }
  56. },
  57. methods: {
  58. changeEvent(event) {
  59. this.$emit('changeEvent', event)
  60. },
  61. tipEvent(item) {
  62. if (!!item.url) {
  63. console.log("点击了轮播图");
  64. }
  65. }
  66. }
  67. }
  68. </script>
  69. <style>
  70. </style>