源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

微信小程序 开发之滑块视图容器(swiper)详解及实例代码

  • 时间:2022-05-24 03:54 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:微信小程序 开发之滑块视图容器(swiper)详解及实例代码
[b]微信小程序 开发之滑块视图容器详解[/b] [b]实现效果图:[/b] [img]http://files.jb51.net/file_images/article/201702/2017022210081011.gif[/img] 实现起来特别简单,看看代码是怎么写的呢:
<swiper class="swiper" indicator-dots="{{indcatorDots}}" autoplay="{{autoPlay}}" interval="{{interval}}" duration="{{duration}}">
 <block wx:for="{{imgUrls}}" wx:for-index="index">
  <swiper-item>
   <image src="{{item}}" class="side-img"></image>
  </swiper-item>
 </block>
</swiper>
这就是布局了,看一下js里面代码:
Page({
  data: {
    imgUrls: [
      'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'],
    indcatorDots: true,
    autoPlay: true,
    interval: 5000,
    duration: 500
  },
,swiper有以下一些常用属性: [img]http://files.jb51.net/file_images/article/201702/2017022210081112.png[/img] 标记的两个属性暂时不管。 [b]注意[/b]:其中只可放置组件,否则会导致未定义的行为。 swiper-item 仅可放置在组件中,宽高自动设置为100%。 就是这样,自己动手试试。 感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部