微信小程序学习之轮播图swiper

轮播图是小程序的重要组件,我们还是好好学滴。

1、上代码,直接布局一个轮播图组件(index.wxml):

复制代码
<swiper class="swiper" indicator-active-color="#fa2c19" indicator-color="#fff" duration="{{duration}}" circular="{{circular}}" autoplay="{{autoplay}}" interval="{{interval}}" indicator-dots="{{indicatorDot}}">
      <swiper-item>
        <image src="https://inews.gtimg.com/news_ls/OAyGfj8q_u9hvn_h8InVmiTqjNaqzwZphygTCTwfhxYvgAA_870492/0" mode="widthFix"/>
      </swiper-item>
      <swiper-item>
        <image src="https://inews.gtimg.com/news_ls/OPxz8FA21MwfVH3gNlRBe2Ps1puF7j9PNdnSZ-LT3F5RgAA_870492/0" mode="widthFix"/>
      </swiper-item>
      <swiper-item>
        <image src="https://inews.gtimg.com/news_ls/OUkUW052LsZR4SEK19nU9fQqkJrLroMkYsPXR9p4LcTB8AA_870492/0" mode="widthFix"/>
      </swiper-item>
    </swiper>

2、轮播图属性的讲解:

indicator-active-color 当前播放页下面指示点的颜色

indicator-color 轮播图下面对应点的颜色

duration 图片切换时动画的播放时间

autoplay 自动切换

circular 采用衔接滑动

interval 切换时间间隔

indicator-dots 显示面板指示点

3、属性的赋值(index.js)

复制代码
Page({
  data: {
    value:'',
    indicatorDot:true,
    autoplay:true,
    interval:3000,
    circular:true,
    duration:1000,
  },
  
})

4、相关样式(index.wxss)

复制代码
.swiper{
  padding: 0 10rpx;
}

image{
  width: 100%;
}

好了,看效果

轮播图

相关推荐
前端缘梦23 分钟前
微信小程序登录方案实践-从账号体系到用户信息存储
前端·微信小程序
布伦鸽44 分钟前
C# WPF 左右布局实现学习笔记(1)
笔记·学习·c#·wpf
陳麦冬2 小时前
深入理解指针(二)
c语言·学习
coding随想4 小时前
2025年小程序开发全解析:技术储备、行业趋势与实战案例
微信小程序
普宁彭于晏4 小时前
CSS3相关知识点
前端·css·笔记·学习·css3
fen_fen5 小时前
学习笔记(25):线性代数,矩阵-矩阵乘法原理
笔记·学习·线性代数
xiaoxiaoxiaolll7 小时前
从理论崩塌到新路径:捷克科学院APL Photonics论文重构涡旋光技术边界
学习
抠脚学代码8 小时前
Ubuntu18.6 学习QT问题记录以及虚拟机安装Ubuntu后的设置
qt·学习·ubuntu
Nueuis11 小时前
微信小程序前端面经
前端·微信小程序·小程序
萌新小码农‍15 小时前
Spring框架学习day7--SpringWeb学习(概念与搭建配置)
学习·spring·状态模式