小程序端工程代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.7 KiB

  1. <template>
  2. <view class="slider-banner product-bg">
  3. <swiper
  4. class="swiper-wrapper"
  5. @change="handleChange"
  6. v-if="imgUrls.length > 0"
  7. >
  8. <block v-for="(item, imgUrlsIndex) in imgUrls" :key="imgUrlsIndex">
  9. <swiper-item>
  10. <image :src="item" @tap="previewImage(imgUrlsIndex)" class="slide-image" />
  11. </swiper-item>
  12. </block>
  13. </swiper>
  14. <!-- <swiper class="swiper-wrapper" :options="ProductConSwiper" v-if="imgUrls.length > 0">
  15. <swiperSlide class="swiper-slide" v-for="item in imgUrls" :key="item" ref="goodSwiper">
  16. <image :src="item" class="slide-image" />
  17. </swiperSlide>
  18. </swiper>-->
  19. <view class="pages">{{ currents || 1 }}/{{ imgUrls.length || 1 }}</view>
  20. </view>
  21. </template>
  22. <script>
  23. // import { swiper, swiperSlide } from "vue-awesome-swiper";
  24. export default {
  25. name: "ProductConSwiper",
  26. components: {
  27. // swiper,
  28. // swiperSlide
  29. },
  30. props: {
  31. imgUrls: {
  32. type: Array,
  33. default: () => [],
  34. },
  35. },
  36. data: function () {
  37. let that = this;
  38. return {
  39. currents: 1,
  40. ProductConSwiper: {
  41. autoplay: {
  42. disableOnInteraction: false,
  43. delay: 2000,
  44. },
  45. loop: true,
  46. speed: 1000,
  47. observer: true,
  48. observeParents: true,
  49. on: {
  50. slideChangeTransitionStart: function () {
  51. that.currents = this.realIndex + 1;
  52. },
  53. },
  54. },
  55. };
  56. },
  57. mounted: function () {},
  58. methods: {
  59. handleChange(event) {
  60. this.currents = event.mp.detail.current + 1;
  61. },
  62. previewImage(current) {
  63. uni.previewImage({
  64. current,
  65. urls: this.imgUrls,
  66. });
  67. },
  68. },
  69. };
  70. </script>