swiper.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <view>
  3. <page-head title="swiper,可滑动视图"></page-head>
  4. <view class="uni-margin-wrap">
  5. <swiper class="swiper" circular :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
  6. <swiper-item>
  7. <view class="swiper-item uni-bg-red">A</view>
  8. </swiper-item>
  9. <swiper-item>
  10. <view class="swiper-item uni-bg-green">B</view>
  11. </swiper-item>
  12. <swiper-item>
  13. <view class="swiper-item uni-bg-blue">C</view>
  14. </swiper-item>
  15. </swiper>
  16. </view>
  17. <view class="swiper-list">
  18. <view class="uni-list-cell uni-list-cell-pd">
  19. <view class="uni-list-cell-db">指示点</view>
  20. <switch :checked="indicatorDots" @change="changeIndicatorDots" />
  21. </view>
  22. <view class="uni-list-cell uni-list-cell-pd">
  23. <view class="uni-list-cell-db">自动播放</view>
  24. <switch :checked="autoplay" @change="changeAutoplay" />
  25. </view>
  26. </view>
  27. <view class="uni-padding-wrap">
  28. <view class="uni-common-mt">
  29. <text>幻灯片切换时长(ms)</text>
  30. <text class="info">{{duration}}</text>
  31. </view>
  32. <slider @change="durationChange" :value="duration" min="500" max="2000" />
  33. <view class="uni-common-mt">
  34. <text>自动播放间隔时长(ms)</text>
  35. <text class="info">{{interval}}</text>
  36. </view>
  37. <slider @change="intervalChange" :value="interval" min="2000" max="10000" />
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. data() {
  44. return {
  45. background: ['color1', 'color2', 'color3'],
  46. indicatorDots: true,
  47. autoplay: true,
  48. interval: 2000,
  49. duration: 500
  50. }
  51. },
  52. methods: {
  53. changeIndicatorDots(e) {
  54. this.indicatorDots = !this.indicatorDots
  55. },
  56. changeAutoplay(e) {
  57. this.autoplay = !this.autoplay
  58. },
  59. intervalChange(e) {
  60. this.interval = e.detail.value
  61. },
  62. durationChange(e) {
  63. this.duration = e.detail.value
  64. }
  65. }
  66. }
  67. </script>
  68. <style>
  69. .uni-margin-wrap {
  70. width:690rpx;
  71. width: 100%;;
  72. }
  73. .swiper {
  74. height: 300rpx;
  75. }
  76. .swiper-item {
  77. display: block;
  78. height: 300rpx;
  79. line-height: 300rpx;
  80. text-align: center;
  81. }
  82. .swiper-list {
  83. margin-top: 40rpx;
  84. margin-bottom: 0;
  85. }
  86. .uni-common-mt{
  87. margin-top:60rpx;
  88. position:relative;
  89. }
  90. .info {
  91. position: absolute;
  92. right:20rpx;
  93. }
  94. .uni-padding-wrap {
  95. width:550rpx;
  96. padding:0 100rpx;
  97. }
  98. </style>