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>
相关推荐
kk晏然6 分钟前
TypeScript 错误类型检查,前端ts错误指南
前端·react native·typescript·react
纆兰16 分钟前
汇款单的完成
前端·javascript·html
Lsx_34 分钟前
案例+图解带你遨游 Canvas 2D绘图 Fabric.js🔥🔥(5W+字)
前端·javascript·canvas
2501_944521001 小时前
rn_for_openharmony商城项目app实战-主题设置实现
javascript·数据库·react native·react.js·ecmascript
m0_471199631 小时前
【场景】如何快速接手一个前端项目
前端·vue.js·react.js
榴莲CC1 小时前
抗干扰LED数显屏驱动VK1624 数码管显示芯片 3线串行接口
前端
lili-felicity1 小时前
React Native for Harmony 个人消息列表最新消息置顶实现(多维度权重统计)
javascript·react native·react.js
Tigger1 小时前
用 Vue 3 做了一套年会抽奖工具,顺便踩了些坑
前端·javascript·vue.js
天天扭码2 小时前
一文搞懂——React 19到底更新了什么
前端·react.js·前端框架
weixin_462446232 小时前
【原创】使用langchain与MCP 与 Chrome DevTools 打造可调用浏览器工具的 Chat Agent
前端·langchain·chrome devtools