uniapp+vue3的defineProps传递

javascript 复制代码
//index.vue
<view class="topic">
			<!-- 磨砂背景 -->
			<view class="content">
				<matte v-for="(item,index) in 8" :key="index"></matte>
				<matte isMore="false"></matte>
			</view>
		</view>
<style scoped lang="scss">
.topic{
			margin-top: 20rpx;
			.content{
				margin-top: 30rpx;
				display: grid;
				gap:10rpx;
				grid-template-columns: repeat(3,1fr);
			}
		}
</style>
javascript 复制代码
//全局组件matte
<template>
	<view class="matte">
		<navigator class="box" url="" v-if="!isMore"> 
			<image class="pic" src="../../common/images/classify1.jpg" mode="aspectFill"></image>
			<view class="top">· 12小时前更新</view>
			<view class="bottom">明星美女</view>
		</navigator>
		<!-- 更多 -->
		<navigator class="box more" url="" v-else>
			<image class="pic" url="../../common/images/more.jpg"></image>
			<view class="bottom">
				<uni-icons type="more-filled" size="30" color="#fff"></uni-icons>
				<view class="text">更多</view>
			</view>
		</navigator>
	</view>
</template>

<script setup>
defineProps({
	isMore:{
		type:Boolean,
		default:false
	}
})	
</script>

<style lang="scss">
	.matte{
		.box{
			height: 340rpx;
			border-radius: 10rpx;
			overflow: hidden;
			position: relative;
			.pic{
				width: 100%;
				height: 100%;
			}
			.top{
				position: absolute;
				top:0;
				left:0;
				background: rgba(250,129,90,0.7);
				padding:4rpx 16rpx;
				font-size: 22rpx;//最小字体
				color: #fff;
				transform: scale(0.8);//缩小字体
				transform-origin: left top;//缩小字体不会移动位置
				border-radius: 0 0 20rpx 0;
			}
			.bottom{
				width: 100%;
				position: absolute;
				display: flex;
				align-items: center;
				justify-content: center;
				left: 0;
				bottom:0;
				height: 70rpx;
				background-color: rgba(0,0,0,0.2);
				backdrop-filter: blur(20rpx);//磨砂效果
				color: #fff;
				font-size: 30rpx;
			}
			
		}
		.box.more{
			.bottom{
				width: 100%;
				height: 100%;
				flex-direction: column;
			}
			.text{
				font-size: 28rpx;
			}
		}
	}
</style>
相关推荐
0思必得025 分钟前
[Web自动化] Selenium处理动态网页
前端·爬虫·python·selenium·自动化
东东5161 小时前
智能社区管理系统的设计与实现ssm+vue
前端·javascript·vue.js·毕业设计·毕设
catino1 小时前
图片、文件的预览
前端·javascript
2501_920931702 小时前
React Native鸿蒙跨平台实现推箱子游戏,完成玩家移动与箱子推动,当所有箱子都被推到目标位置时,玩家获胜
javascript·react native·react.js·游戏·ecmascript·harmonyos
layman05283 小时前
webpack5 css-loader:从基础到原理
前端·css·webpack
半桔3 小时前
【前端小站】CSS 样式美学:从基础语法到界面精筑的实战宝典
前端·css·html
AI老李3 小时前
PostCSS完全指南:功能/配置/插件/SourceMap/AST/插件开发/自定义语法
前端·javascript·postcss
_OP_CHEN3 小时前
【前端开发之CSS】(一)初识 CSS:网页化妆术的终极指南,新手也能轻松拿捏页面美化!
前端·css·html·网页开发·样式表·界面美化
啊哈一半醒3 小时前
CSS 主流布局
前端·css·css布局·标准流 浮动 定位·flex grid 响应式布局
PHP武器库3 小时前
ULUI:不止于按钮和菜单,一个专注于“业务组件”的纯 CSS 框架
前端·css