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

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

相关推荐
Joolun商城源码_Java16 分钟前
JooLun Pro旗舰版SaaS多租户商城:商城小程序与店铺小程序的功能区别详解
小程序
0的0次方17 分钟前
从0到1:如何运营一款支付宝证件照小程序(含避坑指南)
小程序·新媒体运营
小郑加油2 小时前
第16天:综合训练——数据去重
小程序
海兰5 小时前
【小程序】 贪吃蛇(Next.js+WebSocket+SQLite + Prisma ORM)
javascript·websocket·小程序
路光.7 小时前
uniapp小程序/App使用webview打通麦克风权限实现录音功能
小程序·uni-app·app
hnxaoli7 小时前
统信小程序(十四)支持拖拽的旋图程序
python·小程序
2501_915106328 小时前
深入解析HTTPS抓包原理、中间人攻击及反抓包技术攻防
数据库·网络协议·ios·小程序·https·uni-app·iphone
silvia_Anne8 小时前
微信小程序商品列表
微信小程序·小程序
游戏开发爱好者88 小时前
React Grab工具详解:AI助力Vue3、Svelte和Solid前端元素调试
android·ios·小程序·https·uni-app·iphone·webview
维双云9 小时前
做一个教培类做题类型的小程序多少钱?
小程序