当前位置: 首页 > article >正文

uniapp 实现3d轮播图,也就是中间的放大两边的缩小 用swiper和swiper-item就能实现

话不多说,直接上代码,无需引入外部资源, 用swiper和swiper-item就能实现

先上结构代码

<swiper class="header" circular previous-margin="80rpx" next-margin="60rpx" :current="current"
				@change="changeIndex">
				<swiper-item v-for="(item, index) in bannerList" :key="index">
					<!-- 当前所在滑块的 index == index 放大 -->
					<view :class=" current === index ? 'slide-image active' : 'slide-image quiet'">
						<image :src="item.url" style="width: 100%;height: 76%;">
						</image>
						<view class="" style="padding: 0 20rpx;">
							<view class=""
								style="display: flex; color: #000;font-weight: 600;height: 60rpx;align-items: center;justify-content: space-between;">
								<view class="">
									{{item.title}}
								</view>
								<image
									src="https://haowu.shenzhenlinghang.com/uploads/20240924/0e234868d2cff972a73c8299b4f6d7a7.png"
									mode="heightFix" style="height: 50rpx;"></image>
							</view>
							<view class="innnerbox">
								<view class="inner1">
									<view class="inner2" style="width: 70%;height: 100%;background-color: #6ac4b0;border-radius: 15rpx;">

									</view>
								</view>
								<view class="">
									已抢{{item.count}}份
								</view>
							</view>
						</view>
					</view>
				</swiper-item>
			</swiper>

 下面是css部分

.header {
		box-sizing: border-box;
		width: 100%;
		height: 452rpx;

		// margin: 50% auto;
		background-color: #e9f4f2;
		color: #fff;
		border-radius: 10rpx;
		margin-bottom: 50rpx;

		.slide-image {
			width: 600rpx;
			height: 452rpx;
			background: #fff;
			border-radius: 10rpx;

			.innnerbox {
				margin-top: 10rpx;
				height: 20rpx;
				align-items: center;
				display: flex;
				color: #64c1ad;
				font-size: 24rpx;
				justify-content: space-between;

				.inner1 {
					width: 70%;
					background-color:#e7f6f3;
					height: 100%;
					border-radius: 15rpx;
				}
			}
		}

		.active {
			// 中间放大动画
			transform: none;
			transition: all 0.2s ease-in 0s;
		}

		.quiet {
			// 两边缩小动画
			transform: scale(0.95);
			opacity: 0.4;
			transition: all 0.5s ease-in 0s;
		}
	}

还有最关键的js部分代码

const bannerList = ref([{
			url: 'https://haowu.shenzhenlinghang.com/uploads/20240924/deba83e41e2823b2ae91fd54c9c6a701.png',
			count: 5000,
			title: '万益蓝品牌 折扣盛世来袭'
		},
		{
			url: 'https://haowu.shenzhenlinghang.com/uploads/20240924/580881703835073e3a03a79659e77cb5.png',
			count: 5001,
			title: '万益蓝品牌 折扣盛世来袭'
		},
		{
			url: 'https://haowu.shenzhenlinghang.com/uploads/20240924/deba83e41e2823b2ae91fd54c9c6a701.png',
			count: 5002,
			title: '万益蓝品牌 折扣盛世来袭'
		}
	])

	const current = ref(0)
	const changeIndex = (e) => {
		// console.log(e.detail.current, 'e.detail.current');
		current.value = e.detail.current
	}

swiper的属性不懂的可以去看swiper | uni-app官网


http://www.kler.cn/news/323745.html

相关文章:

  • CentOS7 离线部署docker和docker-compose环境
  • 图说数集相等定义表明“R各元x的对应x+0.0001的全体=R“是几百年重大错误
  • c++与Python用笛卡尔的心形函数输出爱心
  • 学习ubuntu 24.10系统目录架构
  • 【Qt】前后端交互---DataCenter类
  • 牛顿迭代法求解x 的平方根
  • 架构师:消息队列的技术指南
  • Unity 网格的细节级别 (LOD) 学习
  • Python Web架构:微服务与服务网格的实践
  • C. Cards Partition 【Codeforces Round 975 (Div. 2)】
  • 强化-极限
  • Netty入门
  • 机器学习(4):机器学习项目步骤(一)——定义问题
  • Pytorch实现Transformer
  • 激光slam学习笔记4--slam_in_autonomous_driving编译碰到问题汇总
  • 基于Python+flask+MySQL+HTML的全国范围水质分析预测系统,可视化用echarts,预测算法随机森林
  • [Redis][Zset]详细讲解
  • FastAPI前置知识及快速入门
  • Python入门:类的异步资源管理与回收( __del__ 方法中如何调用异步函数)
  • CMake构建学习笔记18-cpp-httplib库的构建
  • 【目标检测】隐翅虫数据集386张VOC+YOLO
  • 【web阅读记录】web相关概念及知识整理
  • 【机器学习】——支持向量机
  • uni-app 封装websocket 心跳检测,开箱即用
  • SCAU学习笔记 - 面向对象程序设计课后习题
  • GAMES101(20节,动画和仿真)
  • 如何提升JavaScript安全性,保护应用程序免受威胁
  • Ubuntu 离线安装 docker
  • 深度对比:etcd、Consul、Zookeeper 和 Nacos 作为注册中心和配置中心的优势与劣势
  • 前端请求音频返回pcm流进行播放