微信小程序广告banner、滚动屏怎么做?

使用滑块视图容器swiper和swiper-item可以制作滚动屏,代码如下:

wxml:

html 复制代码
<swiper indicator-dots indicator-color="rgba(255,255,255,0.5)" indicator-active-color="white" autoplay interval="3000">
   <swiper-item>
    <image src=""fakepath://展厅绘制.jpg"/>
  </swiper-item>
  <swiper-item>
    <image src=""fakepath://展会名片.jpg"/>
  </swiper-item>
  <swiper-item>
    <image src=""fakepath://签到.jpg" />
  </swiper-item>
  <swiper-item>
    <image src="fakepath://抽奖.jpg" />
  </swiper-item>
  <swiper-item>
    <image src="fakepath://礼品领取.jpg"/>
  </swiper-item>
</swiper>

wxss:

css 复制代码
swiper image{
  width: 100%;
  height: 100%;
}

效果如下:

其中,swiper常用参数如下,其中只可放置swiper-item组件,否则会导致未定义的行为。:

|------------------------|---------|-------------------|--------|---------------|
| 属性 | 类型 | 默认值 | 必填 | 说明 |
| indicator-dots | boolean | FALSE | 否 | 是否显示面板指示点 |
| indicator-color | color | rgba(0, 0, 0, .3) | 否 | 指示点颜色 |
| indicator-active-color | color | #000000 | 否 | 当前选中的指示点颜色 |
| autoplay | boolean | FALSE | 否 | 是否自动切换 |
| current | number | 0 | 否 | 当前所在滑块的 index |
| interval | number | 5000 | 否 | 自动切换时间间隔 |
| duration | number | 500 | 否 | 滑动动画时长 |

swiper使用细节可见官方文档:

视图容器 / swiper (qq.com)

微信小程序教程,欢迎关注我!

相关推荐
heyCHEEMS21 分钟前
用 分段渲染 解决小程序长列表卡顿问题
前端·微信小程序
CRMEB系统商城34 分钟前
CRMEB标准版系统(PHP)v6.0公测版发布,商城主题市场上线~
java·开发语言·小程序·php
杰克尼1 小时前
苍穹外卖--day11
java·数据库·spring boot·mybatis·notepad++
Dragon Wu2 小时前
Taro 小程序开发注意事项(不定期记录更新)
前端·javascript·小程序·typescript·taro
qq_12498707534 小时前
基于springboot的驾校预约管理小程序(源码+论文+部署+安装)
spring boot·微信小程序·小程序·毕业设计·计算机毕业设计·毕业设计源码
StarChainTech6 小时前
告别“催款”焦虑:如何打造一款高可用、多场景的智能代扣系统
大数据·人工智能·微信小程序·小程序·软件需求
小小王app小程序开发6 小时前
剧本杀狼人杀小程序开发全解析(2026技术版)
小程序
qq_124987075320 小时前
基于SpringBoot微信小程序的智能在线预约挂号系统(源码+论文+部署+安装)
spring boot·后端·微信小程序·毕业设计·计算机毕设·毕业设计源码
程序媛徐师姐21 小时前
Java基于SSM的即时空教室查询小程序,附源码+文档说明
java·微信小程序·小程序·ssm·即时空教室查询小程序·java即时空教室查询小程序·即时空教室查询微信小程序
Dragon Wu1 天前
Taro Webpack 5 编译过慢的解决方案
前端·webpack·小程序·taro