swiper轮播图

妖狐艹你老母 2022-09-05 02:00 324阅读 0赞

swiper中只能放swiper-item
block 并不是一个组件,它仅仅是一个包装元素,不会在页面中做任何渲染,只接受控制属性。

  1. <swiper indicator-dots="{ {indicatorDots}}" autoplay="{ {autoplay}}" interval="{ {interval}}" duration="{ {duration}}">
  2. <block wx:for="{ {imgUrls}}">
  3. <swiper-item>
  4. <image src="{ {item}}" class="slide-image" />
  5. </swiper-item>
  6. </block>
  7. </swiper>
  8. <button bindtap="changeIndicatorDots"> indicator-dots </button>
  9. <button bindtap="changeAutoplay"> autoplay </button>
  10. <slider bindchange="intervalChange" show-value min="500" max="2000"/> interval
  11. <slider bindchange="durationChange" show-value min="1000" max="10000"/> duration
  12. .slide-image{
  13. width: 100%;
  14. height: 100%;
  15. }
  16. Page({
  17. data: {
  18. imgUrls: [
  19. 'https://images.pexels.com/photos/235621/pexels-photo-235621.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500',
  20. 'https://images.pexels.com/photos/1563604/pexels-photo-1563604.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260',
  21. 'https://images.pexels.com/photos/1112186/pexels-photo-1112186.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260'
  22. ],
  23. indicatorDots: false,
  24. autoplay: false,
  25. interval: 5000,
  26. duration: 1000
  27. },
  28. changeIndicatorDots: function(e) {
  29. this.setData({
  30. indicatorDots: !this.data.indicatorDots
  31. })
  32. },
  33. changeAutoplay: function(e) {
  34. this.setData({
  35. autoplay: !this.data.autoplay
  36. })
  37. },
  38. intervalChange: function(e) {
  39. this.setData({
  40. interval: e.detail.value
  41. })
  42. },
  43. durationChange: function(e) {
  44. this.setData({
  45. duration: e.detail.value
  46. })
  47. }
  48. })

请添加图片描述

发表评论

表情:
评论列表 (有 0 条评论,324人围观)

还没有评论,来说两句吧...

相关阅读