微信小程序轮播图

时间:2018-05-07 17:48:28   收藏:0   阅读:559

我们开发web页面的时候,无论是图片还是模块,很多时候会用到轮播,那么下面是微信小程序的轮播功能,也是小程序自带的swiper轮播功能。

下面是轮播展示图:

技术分享图片

 

熟悉一下swiper配置属性,这里的配置属性和我们平时用的轮播插件配置属性差别不大:(点击查看微信小程序开发文档

 技术分享图片 

首先是在wxml文件中加入swiper模块(我这里是把内容模块循环出来的)

<swiper class=‘swiper‘ indicator-dots=‘true‘ autoplay=‘true‘ interval=‘3000‘ duration=‘1000‘>
  <block wx:for=‘{{expers}}‘ wx:for-index=‘index‘>
    <swiper-item>
      <view class=‘exp__list‘>
        <view class=‘__exp_title‘>{{item.title}}</view>
        <view class=‘__exp_tel‘>{{item.content}}</view>
      </view>
    </swiper-item>
  </block>
</swiper>

 

数据来源自wxml对应的js文件

 data: {
    expers:[
      { title:‘北京网易云科技有限公司‘,content:‘13666888866‘ },
      { title: ‘北京网易云科技有限公司‘, content:‘13788668899‘ },
      { title: ‘北京网易云科技有限公司‘, content: ‘13499000077‘ },
      { title: ‘北京网易云科技有限公司‘, content: ‘15288000088‘ },
            
    ]
  },

 

然后在wxss中增加自己想要的样式就可以了。

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!