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

好了,看效果

轮播图

相关推荐
梓彤科技11 小时前
登录状态总是失效,武汉小程序开发怎样设计会话续期与接口鉴权?
微信小程序·小程序·登录鉴权
黑马程序员毕设11 小时前
非遗文化展览系统设计与实现
人工智能·spring boot·后端·微信小程序·毕设
Logintern0911 小时前
【每天学习一点点】超参数是什么?
学习·sklearn
Z59981784111 小时前
c#软件开发学习笔记--WPF(控件、样式)
笔记·学习·c#
Zguigo12 小时前
【DL】神经网络学习目标|prediction|Loss|Gradient
人工智能·神经网络·学习
paopaokaka_luck12 小时前
基于springboot3+vue3+uniapp的剧本杀预约小程序(AI角色对话、协同过滤算法、地图Api、Echarts图形化分析)
java·前端·spring boot·学习·echarts
Logintern0912 小时前
sklearn中pipeline学习
人工智能·学习·sklearn
math_hongfan12 小时前
鸿蒙ArkTS手势交互:拖拽、缩放、旋转与组合手势
学习·华为·交互·harmonyos·鸿蒙
~kiss~12 小时前
Agent Memory System 之 Recent Advance
学习
艾莉丝努力练剑13 小时前
【AI大模型接入SDK】C++日志体系与spdlog封装的理论部分
开发语言·c++·ide·人工智能·学习·面试·trae