前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Vue3.0概要小卡片组件

Vue3.0概要小卡片组件

作者头像
英雄爱吃土豆片
发布2021-12-07 17:10:54
8350
发布2021-12-07 17:10:54
举报

组件

代码语言:javascript
复制
<template>
	<div id="card" :style="cardStyle">
		<div class="main">
			<img class="img" :src="image" :style="imgStyle"/>
			<div class="text">
				<label class="title" :style="titleStyle">{{title}}</label>
				<label class="detail">{{detail}}</label>
			</div>
		</div>
	</div>
</template>

<script>
	export default {
		name: "Card",
		props: {
			image: {
				type: String,
				default: "https://file.zhtsu.cn/light-radius.png"
			},
			title: {
				type: String,
				default: "标题"
			},
			detail: {
				type: String,
				default: "这里是详细信息"
			},
			height: {
				type: String,
				default: "100"
			},
			color: {
				type: String,
				default: "#456D8A"
			}
		},
		data() {
			return {
				ht: this.height,
				cardStyle: "",
				titleColor: this.color,
				titleStyle: "",
				imgStyle: ""
			}
		},
		mounted() {
			this.cardStyle = `width: ${3 * this.ht}px; height: ${this.ht}px;`
			this.imgStyle = `width: ${this.ht - 20}px; height: ${this.ht - 20}px;`
			this.titleStyle = `color: ${this.titleColor}`
		}
	};
</script>

<style scoped>
	.main {
		position: relative;
		width: 100%;
		height: 100%;
		background-color: white;
		background: rgba(255, 255, 255, 0.5);
		box-shadow: 0px 3px 7px 0px rgb(0 0 0 / 35%);
		border-radius: 10px;
		margin: 10px;
	}
	.main:hover {
		background: rgba(255, 255, 255, 0.65);
		transform: scale(102%, 102%);
	}
	.img {
		position: relative;
		width: 80px;
		height: 80px;
		border-radius: 50%;
		top: 50%;
		transform: translateY(-50%);
		margin-left: 10px;
		float: left;
	}
	.text {
		position: relative;
		top: 50%;
		transform: translateY(-50%);
	}
	.title {
		display: block;
		font-size: 24px;
		color: #456D8A;
		margin: 5px;
		font-weight: bold;
		text-shadow: 1px 1px 1px grey;
	}
	.detail {
		display: block;
		font-size: 15px;
		display: block;
		margin: 5px;
		color: #7b7b7b;
	}
</style>

可选参数

参数名

说明

image

图片的在线链接。不支持本地链接

height

卡片的高度。宽度总是为高度的 3 倍

color

卡片右侧上方标题字体颜色

title

卡片右侧上方标题文本

detail

卡片右侧下方详细信息文本

效果图

在这里插入图片描述
在这里插入图片描述
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2021-10-24 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 组件
  • 可选参数
  • 效果图
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档