微信小程序的轮播图和Android的轮播图
2017-06-30 00:00
204 查看
摘要: 微信小程序的轮播图和Android的轮播图一点不一样 ,这里我们看一下我们需要用到的控件介绍
![](https://static.oschina.net/uploads/img/201706/30151638_2M6L.jpg)
![](https://static.oschina.net/uploads/img/201706/30151638_YzWe.jpg)
![](https://static.oschina.net/uploads/img/201706/30151638_PO1f.jpg)
![](https://static.oschina.net/uploads/img/201706/30151639_qxr8.gif)
首先,我们看一下我们的index.wxml文件
index.js文件
index.wxss 这里就是简单的控制了一下显示的样式
微信小程序的轮播图和Android的轮播图一点不一样 ,这里我们看一下我们需要用到的控件介绍
![](https://static.oschina.net/uploads/img/201706/30151638_2M6L.jpg)
这里我们用到了swiper这个组件,上边的图片已经把这个组件的属性 都列出来了 我们用的时候直接用就可以了 接下来,再看一下网络请求的API,这里我们用到的是GET 请求,我们开一下微信小程序官方给我们的API
![](https://static.oschina.net/uploads/img/201706/30151638_YzWe.jpg)
![](https://static.oschina.net/uploads/img/201706/30151638_PO1f.jpg)
接下来就是开启我们小程序轮播图之旅了,附上一张效果图
![](https://static.oschina.net/uploads/img/201706/30151639_qxr8.gif)
首先,我们看一下我们的index.wxml文件
<view> <swiper class="swiper_box" indicator-dots="{{indicatorDots}}" vertical="{{vertical}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" bindchange="swiperchange"> <block wx:for="{{images}}"> <swiper-item> <image src="{{item.picurl}}" class="slide-image" /> </swiper-item> </block> </swiper> </view>
index.js文件
var app = getApp() Page({ /** * 页面的初始数据 */ data: { //是否显示指示点 true 显示 false 不显示 indicatorDots: true, //控制方向 vertical: false, //是否自动切换 autoplay: true, //自动切换时间间隔 interval: 3000, //滑动动画时长 duration: 1000, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this //调用应用实例的方法获取全局数据 app.getUserInfo(function (userInfo) { //更新数据 that.setData({ userInfo: userInfo }) }) //网络请求 GET方法 wx.request({ url: 'http://huanqiuxiaozhen.com/wemall/slider/list', method: 'GET', data: {}, header: { 'Accept': 'application/json' }, //成功后的回调 success: function (res) { console.log('11111' + res), that.setData({ images: res.data }) } }) } })
index.wxss 这里就是简单的控制了一下显示的样式
.swiper_box { width: 100%; } swiper-item image { width: 100%; display: inline-block; overflow: hidden; }
相关文章推荐
- 基于微信api Android程序签名+代码混淆
- 在一个Android应用程序中启动另一个程序(微信)
- 微信小程序(轮播图 swiper组件)
- 微信小程序 轮播图 swiper图片组件
- Android打开指定程序(微博/微信/人人等)
- 微信小程序 swiper组件轮播图详解及实例
- 【微信小程序开发】一名Android开发者的微信小程序填坑之路(微信小程序Demo)
- 一名Android开发者的微信小程序填坑之路(1)
- 微信小程序(五):轮播
- Android能否实现一键清理后台程序后程序自启动(类似QQ微信不被清理软件杀死)
- Android实现微信、QQ的程序前后台切换
- Android打开指定程序(微博/微信/人人等)
- 微信小程序对Android的冲击
- Android打开指定程序(微博/微信/人人等)
- Android 实现微信,QQ的程序前后台切换:back键切换后台;点击通知栏恢复前台。
- Android 实现微信,QQ的程序前后台切换:back键切换后台;点击通知栏恢复前台。
- Android开发-进阶:实现微信自动抢红包的程序
- 一名Android开发者的微信小程序填坑之路(2)