微信小程序学习之轮播图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%;
}

好了,看效果

轮播图

相关推荐
他们叫我阿冠几秒前
Day5学习--SpringBoot详解
spring boot·后端·学习
tedcloud1238 分钟前
hello-agents部署教程:从零学习AI Agent开发
服务器·人工智能·学习·自动化·powerpoint
我想我不够好。18 分钟前
针对性抓人 随机应变
学习
OSwich31 分钟前
【 Godot 4 学习笔记】命名规范
笔记·学习·godot
觅_39 分钟前
前端学习后端的时候 选择一个技术
前端·学习
吃吃今天努力学习了吗1 小时前
【大模型入门学习笔记】常见概念总结
笔记·学习
Bechamz1 小时前
大数据开发学习Day39
大数据·学习
魔法阵维护师2 小时前
从零开发游戏需要学习的c#模块,第十章(设计模式入门)
学习·游戏·设计模式·c#
GEO从入门到精通2 小时前
GEO学习能帮我提高AI搜索排名吗?
人工智能·学习
ᰔᩚ. 一怀明月ꦿ2 小时前
MySQL 学习目标
学习·mysql·adb