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

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

相关推荐
Uyker8 小时前
微信小程序动态效果实战指南:从悬浮云朵到丝滑列表加载
前端·微信小程序·小程序
happyCoder12 小时前
uniapp 微信小程序实现定时消息订阅提醒(前后端)
微信小程序
Uyker21 小时前
从零开始制作小程序简单概述
前端·微信小程序·小程序
打小就很皮...1 天前
HBuilder 发行Android(apk包)全流程指南
前端·javascript·微信小程序
说私域1 天前
定制开发开源AI智能名片驱动下的海报工厂S2B2C商城小程序运营策略——基于社群口碑传播与子市场细分的实证研究
人工智能·小程序·开源·零售
说私域2 天前
内容力重塑品牌增长:开源AI大模型驱动下的智能名片与S2B2C商城赋能抖音生态种草范式
人工智能·小程序·开源·零售
前端缘梦2 天前
微信小程序登录方案实践-从账号体系到用户信息存储
前端·微信小程序
coding随想2 天前
2025年小程序开发全解析:技术储备、行业趋势与实战案例
微信小程序
Nueuis2 天前
微信小程序前端面经
前端·微信小程序·小程序
轩1152 天前
实现仿中国婚博会微信小程序
微信小程序·小程序