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

Day2:前端项目uniapp壁纸实战

先来做一个轮番图。

效果如下:

common-style.css

view,swiper,swiper-item{
	box-sizing: border-box;
}

index.vue

<template>
	<view class="homeLayout">
		<view class="banner">
			<swiper circular indicator-dots autoplay>
				<swiper-item>
					<image src="../../common/images/581c367aa65db_1024.jpg" 
					mode="aspectFill"></image>
				</swiper-item>
				<swiper-item>
					<image src="../../common/images/581c449f64980_1024.jpg"
					mode="aspectFill"></image>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script setup>
	
</script>

<style lang="scss" scoped>
	.homeLayout{
		.banner{
			width: 750rpx;
			padding: 30rpx 0;
			swiper{
				width: 750rpx;
				height: 340rpx;
				swiper-item{
					width: 100%;
					height: 100%;
					padding: 0 30rpx;
					image{
						width: 100%;
						height: 100%;
						border-radius: 10rpx;
					}
				}
			}
		}
	}
</style>

图片素材如下:

可以自己到网上下载图片素材,放到common下的image下

接下来做公告

该音量图标到uniapp官网下载,

步骤如下:

点击下载&安装

下载并导入

按打开

复制基本用法的代码

下滑找到音量

把基本用法的type=“contact”的contact改成sound-filled,可以调整大小和颜色。

如下:

<view class="notice">
			<view class="left">
				<uni-icons type="sound-filled" size="20" color="#28b389"></uni-icons>
				<text class="text">公告</text>
			</view>
			<view class="center">
				
			</view>
			<view class="right">
				
			</view>
		</view>

同理,在right下加个箭头

<view class="right">
				<uni-icons type="right" size="16" color="#333"></uni-icons>
			</view>

效果如下:

调整一下:

<view class="notice">
			<view class="left">
				<uni-icons type="sound-filled" size="20" color="#28b389"></uni-icons>
				<text class="text">公告</text>
			</view>
			<view class="center">
				<swiper vertical autoplay interval="1500"  duration="300" circular>
					<swiper-item v-for="item in 4">文字内容文字内容文字内容文字内容文字内容</swiper-item>
				</swiper>
			</view>
			<view class="right">
				<uni-icons type="right" size="16" color="#333"></uni-icons>
			</view>
		</view>

<style lang="scss" scoped>
	.homeLayout{
		.banner{
			width: 750rpx;
			padding: 30rpx 0;
			swiper{
				width: 750rpx;
				height: 340rpx;
				swiper-item{
					width: 100%;
					height: 100%;
					padding: 0 30rpx;
					image{
						width: 100%;
						height: 100%;
						border-radius: 10rpx;
					}
				}
			}
		}
		.notice{
			width: 690rpx;
			height: 80rpx;
			line-height: 80rpx;
			background: #f9f9f9;
			margin: 0 auto;
			border-radius: 80rpx;
			display: flex;
			.left{
				width: 140rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				.text{
					color: #28b389;
					font-weight: 600;
					font-size: 28rpx;
				}
			}
			.center{
				flex: 1;
				swiper{
					height: 100%;
					swiper-item{
						height: 100%;
						font-size: 30rpx;
						color: #666;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
					}
				}
			}
			.right{
				width: 70rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}
	}
</style>

效果如下:

完整代码如下:

<template>
	<view class="homeLayout">
		<view class="banner">
			<swiper circular indicator-dots autoplay>
				<swiper-item>
					<image src="../../common/images/581c367aa65db_1024.jpg" 
					mode="aspectFill"></image>
				</swiper-item>
				<swiper-item>
					<image src="../../common/images/581c449f64980_1024.jpg"
					mode="aspectFill"></image>
				</swiper-item>
			</swiper>
		</view>
		<view class="notice">
			<view class="left">
				<uni-icons type="sound-filled" size="20" color="#28b389"></uni-icons>
				<text class="text">公告</text>
			</view>
			<view class="center">
				<swiper vertical autoplay interval="1500"  duration="300" circular>
					<swiper-item v-for="item in 4">文字内容文字内容文字内容文字内容文字内容</swiper-item>
				</swiper>
			</view>
			<view class="right">
				<uni-icons type="right" size="16" color="#333"></uni-icons>
			</view>
		</view>
	</view>
</template>

<script setup>
	
</script>

<style lang="scss" scoped>
	.homeLayout{
		.banner{
			width: 750rpx;
			padding: 30rpx 0;
			swiper{
				width: 750rpx;
				height: 340rpx;
				swiper-item{
					width: 100%;
					height: 100%;
					padding: 0 30rpx;
					image{
						width: 100%;
						height: 100%;
						border-radius: 10rpx;
					}
				}
			}
		}
		.notice{
			width: 690rpx;
			height: 80rpx;
			line-height: 80rpx;
			background: #f9f9f9;
			margin: 0 auto;
			border-radius: 80rpx;
			display: flex;
			.left{
				width: 140rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				.text{
					color: #28b389;
					font-weight: 600;
					font-size: 28rpx;
				}
			}
			.center{
				flex: 1;
				swiper{
					height: 100%;
					swiper-item{
						height: 100%;
						font-size: 30rpx;
						color: #666;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
					}
				}
			}
			.right{
				width: 70rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}
	}
</style>

http://www.dtcms.com/a/113001.html

相关文章:

  • #SVA语法滴水穿石# (013)关于内建系统函数
  • Git三剑客:工作区、暂存区、版本库深度解析
  • 王者荣耀的游戏匹配机制
  • 《UNIX网络编程卷1:套接字联网API》第6章 IO复用:select和poll函数
  • 《算法笔记》9.8小节——图算法专题->哈夫曼树 问题 C: 哈夫曼树
  • Java中与、|与||的区别详
  • 算法刷题记录——LeetCode篇(3.9) [第281~290题](持续更新)
  • Kafka 如何调优?
  • 使用MATIO库写入Matlab稀疏矩阵数据的示例程序
  • beego文件上传
  • 【速写】Transformer-encoder-decoder深度解析
  • 8电池_多绕组反激式变压器均衡_4模式
  • AI比人脑更强,因为被植入思维模型【44】成长破圈思维
  • GRE,MGRE
  • VBA第三十八期 VBA自贡分把表格图表生成PPT
  • 借助mcpo在open-webui中使用mcp
  • Oracle Cloud (OCI) 服务器最新控制台启用 IPv6 超详细图文指南(2025最新实践)
  • 2025年 能够有效提升AI的生成质量和逻辑严谨性 的通用型系统提示
  • 使用Android Studio开发基于Java+xml的安卓app之环境搭建
  • 华为:合并LLM以减少冗余推理
  • 蓝桥杯高频考点——经典01背包问题详解(附例题)
  • 前端布局难题:父元素padding导致子元素无法全屏?3种解决方案
  • $R^n$平面约束下的向量列
  • PCL学习(5)随机采样一致性算法RANSAC
  • Maven工具学习使用(七)——Maven属性
  • 从零构建大语言模型全栈开发指南:第三部分:训练与优化技术-3.1.2Tokenization策略:BPE算法与词表设计
  • 4.5蓝桥入门赛题解
  • 高级:分布式系统面试题精讲
  • ARXML文件解析-2
  • STL剖析