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>
相关推荐
AndyGoWei12 分钟前
pnpm 是什么,看这篇文章就够了
前端·javascript
zl0_00_019 分钟前
isctf2025 部分wp
linux·前端·javascript
西洼工作室20 分钟前
移动开发常见问题
前端·css3·web移动开发
同学8079629 分钟前
新版本Chrome谷歌浏览器访问本地网络请求跨域无法正常请求
前端·http
儿歌八万首30 分钟前
Jetpack Compose 实战:打造高性能轮播图 (Carousel) 组件
android·前端·kotlin
m0_6161884933 分钟前
循环多个表单进行表单校验
前端·vue.js·elementui
奋斗猿42 分钟前
五年前端复盘:模块化开发的3个阶段,从混乱到工程化
前端
奋斗猿1 小时前
中级前端避坑指南:图片优化没那么简单,这5招让页面快到飞起
前端
布茹 ei ai1 小时前
地表沉降监测分析系统(vue3前端+python后端+fastapi+网页部署)(开源分享)
前端·python·fastapi
不一样的少年_1 小时前
WebTab等插件出事后:不到100行代码,带你做一个干净透明的新标签页
前端·javascript·浏览器