课程表

微信小程序框架

微信小程序组件

微信小程序API

微信小程序开放接口

微信小程序工具

微信小程序设计规范

工具箱
速查手册

小程序 滑块视图容器

当前位置:免费教程 » 移动开发 » 微信小程序

swiper

滑块视图容器。

属性名类型默认值说明
indicator-dotsBooleanfalse是否显示面板指示点
indicator-colorColorrgba(0, 0, 0, .3)指示点颜色
indicator-active-colorColor#000000当前选中的指示点颜色
autoplayBooleanfalse是否自动切换
currentNumber0当前所在页面的 index
intervalNumber5000自动切换时间间隔
durationNumber500滑动动画时长
circularBooleanfalse是否采用衔接滑动
bindchangeEventHandle current 改变时会触发 change 事件,event.detail = {current: current}

注意:其中只可放置<swiper-item/>组件,否则会导致未定义的行为。

swiper-item

仅可放置在<swiper/>组件中,宽高自动设置为100%。

示例代码:

  1. <swiper indicator-dots="{{indicatorDots}}"
  2. autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
  3. <block wx:for="{{imgUrls}}">
  4. <swiper-item>
  5. <image src="{{item}}" class="slide-image" width="355" height="150"/>
  6. </swiper-item>
  7. </block>
  8. </swiper>
  9. <button bindtap="changeIndicatorDots"> indicator-dots </button>
  10. <button bindtap="changeAutoplay"> autoplay </button>
  11. <slider bindchange="intervalChange" show-value min="500" max="2000"/> interval
  12. <slider bindchange="durationChange" show-value min="1000" max="10000"/> duration
  1. Page({
  2. data: {
  3. imgUrls: [
  4. 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
  5. 'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
  6. 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
  7. ],
  8. indicatorDots: false,
  9. autoplay: false,
  10. interval: 5000,
  11. duration: 1000
  12. },
  13. changeIndicatorDots: function(e) {
  14. this.setData({
  15. indicatorDots: !this.data.indicatorDots
  16. })
  17. },
  18. changeAutoplay: function(e) {
  19. this.setData({
  20. autoplay: !this.data.autoplay
  21. })
  22. },
  23. intervalChange: function(e) {
  24. this.setData({
  25. interval: e.detail.value
  26. })
  27. },
  28. durationChange: function(e) {
  29. this.setData({
  30. duration: e.detail.value
  31. })
  32. }
  33. })
转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号