微信小程序(九)轮播图

注释很详细,直接上代码

上一篇

新增内容:
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;
}

效果演示:

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

相关推荐

  1. 程序九宫格布局,

    2024-01-24 19:54:04       64 阅读
  2. 程序实现

    2024-01-24 19:54:04       38 阅读
  3. 程序

    2024-01-24 19:54:04       30 阅读
  4. 程序 且跳转公众号文章

    2024-01-24 19:54:04       47 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-24 19:54:04       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-24 19:54:04       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-24 19:54:04       87 阅读
  4. Python语言-面向对象

    2024-01-24 19:54:04       96 阅读

热门阅读

  1. 1.20号网络

    2024-01-24 19:54:04       52 阅读
  2. 民安智库-医院职工满意度调查报告如何撰写

    2024-01-24 19:54:04       48 阅读
  3. MongoDB基本常用命令(一)

    2024-01-24 19:54:04       52 阅读
  4. Scikit-Learn 中级教程——学习曲线

    2024-01-24 19:54:04       57 阅读
  5. Scikit-Learn 中级教程——特征缩放

    2024-01-24 19:54:04       54 阅读
  6. 【MySQL】Char与VarChar详解

    2024-01-24 19:54:04       59 阅读