微信小程序广告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)

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

相关推荐
seeyoutlb20 小时前
微信小程序登录
微信小程序·小程序
Jing_Rainbow1 天前
【Weapp-2 /Lesson19(2025-11-04)】微信小程序“博客园”项目深度解析:从架构到细节的完整剖析📱
微信·微信小程序·程序员
小皮虾1 天前
拒绝卡顿!小程序图片本地“极速”旋转与格式转换,离屏 Canvas 性能调优实战
前端·javascript·微信小程序
毕设源码-邱学长1 天前
【开题答辩全过程】以 基于微信小程序的农商新闻网为例,包含答辩的问题和答案
微信小程序·小程序
小光学长1 天前
基于微信小程序的家具商城系统g80l9675(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
数据库·微信小程序·小程序
云起SAAS1 天前
1V1七彩测评抖音快手微信小程序看广告流量主开源
微信小程序·小程序·ai编程·看广告变现轻·1v1七彩测评
sheji34161 天前
【开题答辩全过程】以 基于微信小程序的签到系统的设计与实现为例,包含答辩的问题和答案
微信小程序·小程序
说私域1 天前
基于开源链动2+1模式AI智能名片S2B2C商城小程序的社群运营创新研究
人工智能·小程序·开源
chinrock1 天前
如何抓包飞书小程序-飞书开发者工具
小程序·飞书
Jing_Rainbow2 天前
【 Weapp-1 /Lesson18(2025-11-03)】# 微信小程序开发全解析:从项目结构到生态优势 🚀
微信·微信小程序·程序员