微信小程序开发02-设置自动滚动轮播图片

设置自动滚动图片首先在xx.xml中:

<swiper class="banner" indicator-dots indicator-color="rgba(255,255,255,0.5)" indicator-active-color="#fff" autoplay interval="3000" circular>
  <swiper-item>
    <image src="../../image/h14.jpg"  mode="widthFix"></image>
  </swiper-item>
  <swiper-item>
    <image src="../../image/h2.jpg" mode="widthFix"></image>
  </swiper-item>
  <swiper-item>
    <image src="../../image/h3.jpg" mode="widthFix"></image>
  </swiper-item>
</swiper>

在.wxss中对其进行样式渲染(具体大小等,可以对参数稍做更改):

.banner{height: 400rpx; border: red 1px solid;}
.banner image{height: 400rpx; width: 100%;}

.srcOut{display: flex; flex-wrap: nowrap; text-align: center;}

.srcBox{ width: 100px; height: 100px; background-color: gold; margin: 2px; flex:0 0 100px}
.srcOut .txt{font-size: 35rpx; color: #FF69B4; background-color: #FFF8DC;}

.srcOut2{ height: 100%;
}
.srcBox2{width: 100%; height: 100px; background-color: hotpink; margin-bottom: 1px;}


.out{padding: 30rpx;box-sizing: border-box  ;}
.row{display: flex;height: 150rpx;margin-bottom: 20rpx;}
.pic{flex: 2;}
.pic image{width: 100%; height: 100%;}
.text{flex: 8; border-bottom: solid 1px #eee;padding-left: 10rpx; display: flex; flex-direction: column;justify-content: space-between;}
.text .title{font-size: 38rpx;}
.text .time{ color: #999;}

.footer{padding: 40rpx 0; background: #f2f2f2; text-align: center;}
.footer .pic{width: 60rpx;}
.footer .text{font-size: 25rpx; color: #999;}

功能描述

滑块视图容器。其中只可放置swiper-item组件,否则会导致未定义的行为。

属性说明

属性类型默认值必填说明最低版本
indicator-dotsbooleanfalse是否显示面板指示点1.0.0
indicator-colorcolorrgba(0, 0, 0, .3)指示点颜色1.1.0
indicator-active-colorcolor#000000当前选中的指示点颜色1.1.0
autoplaybooleanfalse是否自动切换1.0.0
currentnumber0当前所在滑块的 index1.0.0
intervalnumber5000自动切换时间间隔1.0.0
durationnumber500滑动动画时长1.0.0
circularbooleanfalse是否采用衔接滑动1.0.0
verticalbooleanfalse滑动方向是否为纵向1.0.0
previous-marginstring"0px"前边距,可用于露出前一项的一小部分,接受 px 和 rpx 值1.9.0
next-marginstring"0px"后边距,可用于露出后一项的一小部分,接受 px 和 rpx 值1.9.0
snap-to-edgebooleanfalse当 swiper-item 的个数大于等于 2,关闭 circular 并且开启 previous-margin 或 next-margin 的时候,可以指定这个边距是否应用到第一个、最后一个元素2.12.1
display-multiple-itemsnumber1同时显示的滑块数量1.9.0
easing-functionstring"default"指定 swiper 切换缓动动画类型2.6.5
  • 6
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林代码er

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值