sh-banner.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <!-- 轮播 -->
  3. <view class="banner-swiper-wrap u-m-b-10" :style="{ padding: `${Py}rpx ${Px}rpx` }">
  4. <swiper
  5. :style="{ minHeight: height + 'rpx', height: height + 'rpx' }"
  6. class="screen-swiper square-dot"
  7. :indicator-dots="true"
  8. :circular="true"
  9. :autoplay="true"
  10. interval="5000"
  11. duration="500"
  12. >
  13. <swiper-item :style="{ borderRadius: borderRadius + 'rpx' }" v-for="(item, index) in list" :key="index" @tap="onSwiper(index)">
  14. <image :src="item.image" mode="aspectFill"></image>
  15. </swiper-item>
  16. </swiper>
  17. </view>
  18. </template>
  19. <script>
  20. /**
  21. * shBanner-轮播卡片
  22. * @property {Array} list 轮播图数据,
  23. * @property {String Number} height 轮播图组件高度,单位rpx(默认250)
  24. * @property {String} borderRadius 圆角值
  25. * @event {Function} click 点击轮播图时触发
  26. */
  27. export default {
  28. components: {},
  29. data() {
  30. return {};
  31. },
  32. props: {
  33. Px: {
  34. type: [Number, String],
  35. default: 0
  36. },
  37. Py: {
  38. type: [Number, String],
  39. default: 0
  40. },
  41. // 轮播图的数据,格式如:[{image: 'xxxx', title: 'xxxx'},{image: 'yyyy', title: 'yyyy'}],其中title字段可选
  42. list: {
  43. type: Array,
  44. default() {
  45. return [];
  46. }
  47. },
  48. // 圆角值
  49. borderRadius: {
  50. type: [Number, String],
  51. default: 0
  52. },
  53. // list的高度,单位rpx
  54. height: {
  55. type: [Number, String],
  56. default: 250
  57. }
  58. },
  59. computed: {},
  60. methods: {
  61. onSwiper(e) {
  62. this.$tools.routerTo(this.list[e].path);
  63. }
  64. }
  65. };
  66. </script>
  67. <style lang="scss" scoped></style>