swiper组件是(shi)微信滑块视图容器,主要用来做(zuo)图片轮播。小程序轮详解这篇文章主要(yao)给(gei)大家介绍了关于微信小程(cheng)序轮播图swiper代码的播图相关(guan)资(zi)料,需要的朋友可以参考下
微信小程序自(zi)定义swiper

滑块视图容器。其(qi)中只可放置swiper-item组件,代码否则会导致未定义的微信行为。

style=“background:{ { item}}” 报错不要管,小程序轮详解不(bu)影响页面布局

<view class='container'>
<swiper class="swiper1"
indicator-dots='{ { indicatorDots}}' 是播图(tu)否显示面板指(zhi)示点
autoplay="autoplay"="{ { autoplay='autoplay'}}" 是否自动切换
interval='{ { interval}}' 自动切(qie)换时间间隔
duration='{ { duration}}' 滑动动(dong)画时长
circular='{ { circular}}' 是否采用衔接(jie)滑动
indicator-active-color='#ff0099' 选中指示点颜色
>
<block wx:for="{ { background}}" wx:key='index'> 循环遍历数据
<swiper-item>
<view class='swiper-item' style='background:{ { item}}'></view>
</swiper-item>
</block>
</swiper>
</view>
Page({
data: {
background: ["red", "pink","yellowgreen"],
indicatorDots: true,
vertical: false,
autoplay="autoplay": true,
interval: 2000,
duration: 500,
circular:true
}
})
最后在index.wxss中写
.swiper1{
width: 100%;
height: 200px;
}
.swiper-item{
width: 100%;
height: 100%;
}
记住:
图片跟背景颜色思路一样
到此这篇关于微信小程(cheng)序轮播图swiper代码的文章就(jiu)介绍到这了(le),更多(duo)相关微信小程序轮播图swiper代码内容请搜索脚本之家以(yi)前(qian)的文(wen)章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
代码来源:脚本之家
代码链接:https://www.jb51.net/article/201081.htm
代码