首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >[微信小程序][转载]swiper轮播图控件使用

[微信小程序][转载]swiper轮播图控件使用

作者头像
云未归来
发布2025-07-18 14:09:22
发布2025-07-18 14:09:22
1340
举报

wxml文件

<!--

1 轮播图外层容器 swiper

2 每一个轮播项 swiper-item

3 swiper标签 存在默认样式

1 width 100%

2 height 150px image 存在默认宽度和高度 320 * 240

3 swiper 高度 无法实现由内容撑开

4 先找出来 原图的宽度和高度 等比例 给swiper 定 宽度和高度

原图的宽度和高度 1125 * 352 px

swiper 宽度 / swiper 高度 = 原图的宽度 / 原图的高度

swiper 高度 = swiper 宽度 * 原图的高度 / 原图的宽度

height: 100vw * 352 / 1125

5 autoplay 自动轮播

6 interval 修改轮播时间

7 circular 衔接轮播

8 indicator-dots 显示 指示器 分页器 索引器

9 indicator-color 指示器的未选择的颜色

10 indicator-active-color 选中的时候的指示器的颜色

-->

<swiper autoplay interval="1000" circular indicator-dots indicator-color="#0094ff" indicator-active-color="#ff0094">

<swiper-item> <image mode="widthFix" src="//gw.alicdn.com/imgextra/i1/44/O1CN013zKZP11CCByG5bAeF_!!44-0-lubanu.jpg" /> </swiper-item>

<swiper-item> <image mode="widthFix" src="//aecpm.alicdn.com/simba/img/TB1CWf9KpXXXXbuXpXXSutbFXXX.jpg_q50.jpg" /> </swiper-item>

<swiper-item> <image mode="widthFix" src="//gw.alicdn.com/imgextra/i2/37/O1CN01syHZxs1C8zCFJj97b_!!37-0-lubanu.jpg" /> </swiper-item>

</swiper>

wxss文件

/* pages/demo10/demo10.wxss */

swiper {

width: 100%;

/* height: calc(100vw * 352 / 1125); */

height: 31.28vw;

}

image {

width: 100%;

}

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2025-07-17,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档