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>
相关推荐
青皮桔1 分钟前
CSS实现百分比水柱图
前端·css
失落的多巴胺1 分钟前
使用deepseek制作“喝什么奶茶”随机抽签小网页
javascript·css·css3·html5
DataGear5 分钟前
如何在DataGear 5.4.1 中快速制作SQL服务端分页的数据表格看板
javascript·数据库·sql·信息可视化·数据分析·echarts·数据可视化
影子信息6 分钟前
vue 前端动态导入文件 import.meta.glob
前端·javascript·vue.js
青阳流月8 分钟前
1.vue权衡的艺术
前端·vue.js·开源
样子201812 分钟前
Vue3 之dialog弹框简单制作
前端·javascript·vue.js·前端框架·ecmascript
kevin_水滴石穿13 分钟前
Vue 中报错 TypeError: crypto$2.getRandomValues is not a function
前端·javascript·vue.js
翻滚吧键盘13 分钟前
vue文本插值
javascript·vue.js·ecmascript
孤水寒月1 小时前
给自己网站增加一个免费的AI助手,纯HTML
前端·人工智能·html
CoderLiu1 小时前
用这个MCP,只给大模型一个figma链接就能直接导出图片,还能自动压缩上传?
前端·llm·mcp