当前位置:网站首页>微信小程序实现轮播图(自动切换&手动切换)
微信小程序实现轮播图(自动切换&手动切换)
2022-07-25 09:21:00 【乐玩兔】

需求
- 轮播图自动循环切换
- 控制轮播图的速度和切换间隔
- 本地图片 的切换
- 联网图片(即给定图片url集的切换)
步骤
- 微信小程序给出了相关的组件可以直接拿来用就行
- 里面封装了很好的功能,包括速度的控制和切换
- 实现本地图片的切换(单机版)
- 实现联网请求的切换(联网版)
代码实现
index.wxml
<view class="swiper-container">
<!-- <image calss="swiper-imgs" src="../../image/index2.png"> </image> -->
<swiper class='swiper_box' indicator-dots='{
{indicatorDots}}' autoplay='{
{autoplay}}' circular='{
{circular}}' indicator-color='#fff000' indicator-active-color='#ff0000'>
<block wx:for="{
{images}}" wx:key="id">
<swiper-item>
<image class='image_banner' src='../../image/{
{item}}'></image>
</swiper-item>
</block>
</swiper>
</view>
index.js
Page({
data:{
indicatorDots:true,
circular:true,
autoplay:true,
images: ['index1.png', 'index2.png', 'index3.png', 'index4.png', 'index5.png']
}
})
index.wxss
@import "../../libs/weui.wxss";
page {
background-color: #F8F8F8;
height: 100%;
font-size: 32rpx;
line-height: 1.6;
}
.image_banner{
position: relative;
align-items: center;
justify-content: center;
background-color: #1AAD19;
color: #FFFFFF;
font-size: 36rpx;
}
.image_banner:before{
display: block;
top:50%;
left:50%
}
index.json
{
"navigationBarTitleText": "首页"
}
微信集成了各个组件的功能,可以直接拿来使用即可,包括轮播图中图片的切换速度和时间控制,直接给相关属性赋值即可做到
微信小程序组件应用
https://developers.weixin.qq.com/miniprogram/dev/component/navigation-bar.html
Demo链接
https://github.com/EugeniaGao/miniProgram
边栏推荐
猜你喜欢

Browser access to swagger failed with error err_ UNSAFE_ PORT

【代码源】每日一题 - 排队

STM32+HC05串口蓝牙设计简易的蓝牙音箱

如何将Jar包部署到服务器,注:启动命令有无nohup有很大关系

uni-app小程序如何自定义标题内容(如何解决小程序标题不居中)

Install MySQL in Ubuntu and create new users

Operation 7.19 sequence table

Flex layout syntax and use cases
![[GKCTF 2021]easynode](/img/f0/1daf6f83fea66fdefd55608cbddac6.png)
[GKCTF 2021]easynode

那天帮妹纸装了个数据库。。。就又帮她整理了篇快捷键
随机推荐
Idea hot deployment
Redis set 结构命令
Jar包在阿里云服务器起起来了,安全组也开通了,但postman仍跑不通怎么办
【代码源】每日一题 - 排队
A brief introduction to the interest of convolutional neural networks
如何将Jar包部署到服务器,注:启动命令有无nohup有很大关系
语音聊天app源码-钠斯网络源码出品
单例模式(Singleton)
【代码源】每日一题 非递减01序列
【代码源】每日一题 树
[GYCTF2020]Ez_ Express
[HCTF 2018]admin
Assignment 7.21 Joseph Ring problem and decimal conversion
Data control language (DCL)
为什么要使用JSON.stringify()和JSON.parse()
Go基础2
用kotlin怎么写Android切换界面
机器学习 —— Sklearn包中StandardScaler()、transform()、fit()的详细介绍
STM32+HC05串口蓝牙设计简易的蓝牙音箱
Go foundation 1