微信小程序(九)轮播图

注释很详细,直接上代码

上一篇

新增内容:
1.轮播容器的基本属性
2.轮播图片的尺寸处理

index.wxml

<view class="navs">
    <text class="active">精选</text>
    <text>手机</text>
    <text>食品</text>
    <text>内衣</text>
    <text>生鲜</text>
    <text>母婴</text>
</view> 

//indicator-dots显示面板指示点
//indicator-active-color当前选中的指示点颜色
//autoplay 自动切换
//circular是否采用衔接滑动
//duration滑动动画时长(单位ms)
//interval自动切换时间间隔(单位ms)
<swiper indicator-dots indicator-active-color="#bb3b2e" autoplay circular duration="1000" interval="2000"> 
    <swiper-item>
        <image src="/static/uploads/slide_1.jpg"></image>    
    </swiper-item>

    <swiper-item>
        <image src="/static/uploads/slide_2.jpg"></image>    
    </swiper-item>

    <swiper-item>
        <image src="/static/uploads/slide_3.jpg"></image>    
    </swiper-item>
</swiper>

index.wxss

.navs{
    display: flex;
    justify-content: space-evenly;
    background-color: white;
    height:40px;
    align-items: center;
    font-size: 14px;
}

.active{
    color: #37b626;
    border-bottom: 1px solid #00b26a;
}

//设置滑动视图容器大小
swiper{
    width: 750rpx;
    height: 320rpx;
}

//设置图片大小(因图片而异,最好是图片本身就适配的)
swiper image{
    width: 750rpx;
    height: 320rpx;
}

效果演示:

在这里插入图片描述
下一篇

  • 23
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

代码对我眨眼睛

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

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

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

打赏作者

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

抵扣说明:

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

余额充值