怎么用小程序swiper组件实现点击图片切换效果(swiper,小程序,开发技术)

时间:2024-05-07 16:55:29 作者 : 石家庄SEO 分类 : 开发技术
  • TAG :

  小程序swiper组件实现点击图片轮播切换的效果,还是比较简单的。

  比如:

  1.index.wxml

<!--index.wxml-->

<swiper class="swiper" indicator-dots="true" autoplay="true" interval="5000" duration="1000">

<block wx:for="{{movies}}" wx:for-index="index">

<swiper-item>

<image src="{{item.url}}" class="slide-image" mode="aspectFill"/>

</swiper-item>

</block>

</swiper>

  这里有几个属性需要说明.

怎么用小程序swiper组件实现点击图片切换效果

  微信小程序开发的循环用到了

  我这里是遍历movies[]数组.就是item

  2.index.js

//index.js

//获取应用实例

var app = getApp()

Page({

data: {

movies:[

{url:'http://img04.tooopen.com/images/20130712/tooopen_17270713.jpg'} ,

{url:'http://img04.tooopen.com/images/20130617/tooopen_21241404.jpg'} ,

{url:'http://img04.tooopen.com/images/20130701/tooopen_20083555.jpg'} ,

{url:'http://img02.tooopen.com/images/20141231/sy_78327074576.jpg'}

]

},

onLoad: function () {

}

})

  3.WXML

  /**index.wxss**/

  .swiper {

  height: 400rpx;

  width: 100%;

  }

  .swiper image {

  height: 100%;

  width: 100%;

  }

 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:怎么用小程序swiper组件实现点击图片切换效果的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:小程序收款码需要什么资格才能申请下一篇:

6 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18