微信小程序轮播图swiper代码详解
zhuxiaoqiang · 1032浏览 · 发布于2020-12-04
swiper组件是滑块视图容器,主要用来做图片轮播。这篇文章主要给大家介绍了关于微信小程序轮播图swiper代码的相关资料,需要的朋友可以参考下
微信小程序自定义swiper
滑块视图容器。其中只可放置swiper-item组件,否则会导致未定义的行为。
style=“background:{{item}}” 报错不要管,不影响页面布局
<swiper class="swiper1"
indicator-dots="{{indicatorDots}}" 是否显示面板指示点
autoplay="{{autoplay}}" 是否自动切换
interval="{{interval}}" 自动切换时间间隔
duration="{{duration}}" 滑动动画时长
circular="{{circular}}" 是否采用衔接滑动
indicator-active-color="#ff0099" 选中指示点颜色
>
再在index.js中写
Page({
data: {
background: ["red", "pink","yellowgreen"],
indicatorDots: true,
vertical: false,
autoplay: true,
interval: 2000,
duration: 500,
circular:true
}
})
最后在index.wxss中写
.swiper1{
width: 100%;
height: 200px;
}
.swiper-item{
width: 100%;
height: 100%;
}
记住:
图片跟背景颜色思路一样
相关推荐
android下vulkan与opengles纹理互通
talkchan · 1174浏览 · 2020-11-23 10:37:39
Android 使用RecyclerView实现轮播图
奔跑的男人 · 2172浏览 · 2019-05-09 17:11:13
微软发布新命令行工具 Windows Terminal
吴振华 · 867浏览 · 2019-05-09 17:15:04
在华为写了十几年代码,我为什么还没有被拿去“祭天”
追忆似水年华 · 1199浏览 · 2019-05-09 17:22:20
android 通过修改图片像素实现CircleImageView
吴振华 · 1126浏览 · 2019-05-09 22:26:56
我爱编程,我爱工作,更爱生活
分类专栏
最新发布
最热排行
0评论