swiper-image.vue 1.6 KB

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