swiper组件构建小程序轮播图

来源:互联网 发布:爱淘宝流氓软件 编辑:程序博客网 时间:2024/05/18 16:14

这里写图片描述


  • wxml基础文件:
<view class="classname">    <swiper indicator-dots="true" interval="1000" autoplay="true" indicator-active-color="red">        <swiper-item><image src="/images/1.jpg"></image></swiper-item>        <swiper-item><image src="/images/2.jpg"></image></swiper-item>        <swiper-item><image src="/images/3.jpg"></image></swiper-item>    </swiper> </view> 

swiper-item仅可放置在组件中,宽高自动设置为100%。
参数设置:
autoplay 自动播放导致swiper变化;
touch 用户划动引起swiper变化;
indicator-dots true是否显示面板指示点圆圈;
interval 自动切换时间间隔;
duration 滑动动画时长;
更多设置可以看官方文档组件!

  • wxss样式文件
swiper{  width:100%;  height:500rpx;}swiper image{   width:100%;  height:500rpx;}
  • app.json文件入口
{  "pages": [    "pages/redirect/redirect"     ],  "window": {    "navigationBarBackgroundColor": "#405f80"  }}

若她涉世未深,就带她看尽人间繁华;若她心已沧桑,就带她坐旋转木马。