当前位置:网站首页>小程序模拟淘宝京东商品轮播滑动展示功能模块
小程序模拟淘宝京东商品轮播滑动展示功能模块
2022-08-08 21:03:00 【皮皮灬虾】
小程序模拟淘宝京东商品轮播滑动展示功能模块
多话不说直接上传代码
一、wxml代码模块如下:
<!--轮播图-->
<swiper autoplay="{
{autoplay}}" interval="{
{interval}}" duration="{
{duration}}" circular="true" bindchange="swiperChange" current="{
{swiperCurrent}}">
<block wx:for="{
{imgUrls}}" wx:key="{
{index}}">
<swiper-item>
<image src="{
{item}}" data-index="{
{index}}" class="slide-image" />
</swiper-item>
</block>
</swiper>
<!-- 实现点击选中样式 -->
<!-- <scroll-view scroll-x="true"> -->
<view class="dots">
<block wx:for="{
{imgUrls}}" wx:for-index="index" wx:key>
<view class="dot{
{index == swiperCurrent ? ' active' : ''}}" bindtap="chuangEvent" id="{
{index}}">
<image src="{
{item}}" />
</view>
</block>
</view>
<!-- </scroll-view> -->
二、css样式模块
/*轮播图*/
swiper {
height: 360rpx;
width: 750rpx;
}
.slide-image {
width: 100%;
height: 360rpx;
}
/*滚动条*/
.dots{
display: flex;
white-space: nowrap;
background-color: #fff;
}
.dot{
width: 300rpx;
height: 100rpx;
display: inline-block;
margin: 20rpx;
border: 1px solid rgba(169, 169, 169, 0.507);
}
.dot image{
width: 100%;
height: 100%;
display: block;
}
.active{
height: 120rpx;
}
三、js代码模块
data: {
/*轮播图数据*/
imgUrls: [
'/images/xiangqing/1.png',
'/images/xiangqing/2.png',
'/images/xiangqing/3.png',
'/images/xiangqing/4.png'
],
swiperCurrent: 0,//默认显示第一个
autoplay: true,//自动轮播
interval: 3000,
duration: 1500,
},
//轮播图的切换事件
swiperChange: function (e) {
var that = this;
that.setData({
swiperCurrent: e.detail.current //获取当前轮播图片的下标
})
},
//点击指示点切换
chuangEvent: function (e) {
var that = this;
that.setData({
swiperCurrent: e.currentTarget.id
})
},
还是那句话,希望对你们有所帮助,如有疑问,欢迎留言,我会及时回复的!希望大家一起探讨,共同进步!!!
边栏推荐
- The new database is online | CnOpenData information transmission, software and information technology service industry basic information data of industrial and commercial registered enterprises
- C语言斐波那锲数列前n项求和
- GeoServer入门学习:01-开篇
- GeoServer Getting Started Learning: 06-Publishing Multi-level TIF Map Data
- 【JVM内存区域】
- fashion CNNs code
- 编译原理——词法分析程序(C#)
- go基于泛型实现继承
- 【idea_取消自动import .*】
- 磁控胶囊胃镜:具有良好耐受性的非侵入性胃镜检查
猜你喜欢
随机推荐
【Excel template download with information】
去噪论文 Beyond a Gaussian Denoiser: Residual Learning of Deep CNN for Image Denoising
IO in Kotlin flow
drf-树形结构的model的序列化显示
图像噪声水平估计INLE_paper
【访问本地项目,localhosthost可以,本地ip不可以】
【浏览器打开导出的excel】
Kotlin's JSON format parsing
Redis Bloom Filter
day9 FastDFS
jmeter逻辑控制器使用
编译原理——LL1分析程序实验(C#)
go实现快速排序
SQL-堆叠注入(含例题)
Jenkins下载安装
文档图像二值化DIB_paper_1
二叉树前序遍历、中序遍历、后序遍历的迭代版
复合索引使用
推荐7款好用的Visual Studio扩展
Everything原理探究以及C#实现





