当前位置: 首页 > news >正文

vue 封装流动的线组件(支持实线, 虚线, 变色, 流动)

vue 封装流动的线组件(支持实线, 虚线, 变色, 流动)

<template>
	<div
		class="lineBody"
		:class="{ lineBodyRed: isRed }"
		:style="{ position: 'absolute', left: left + 'px', top: top + 'px', width: width + 'px', transform: `rotate(${angle}deg)` }"
	>
		<!-- 实线 正常 -->
		<div v-if="!isDash && !isFlow && !isRed" class="noFlowBody"></div>
		<!-- 实线 红色 -->
		<div v-if="!isDash && !isFlow && isRed" class="noFlowBodyRed"></div>

		<!-- 虚线 流动 正常 -->
		<div v-if="isFlow && !isRed" class="dashFlowLine"></div>
		<!-- 虚线 流动 红色 -->
		<div v-if="isFlow && isRed" class="dashFlowLineRed"></div>
		<!-- 虚线 不流动 正常 -->
		<div v-if="!isFlow && !isRed" class="dashNoflowLine"></div>
		<!-- 虚线 不流动 红色 -->
		<div v-if="!isFlow && isRed" class="dashNoflowLineRed"></div>
	</div>
</template>

<script>
export default {
	props: {
		left: {
			type: [Number, String],
			default: 0,
		},
		top: {
			type: [Number, String],
			default: 0,
		},
		width: {
			type: [Number, String],
			default: 0,
		},
		// 旋转角度
		angle: {
			type: [Number, String],
			default: 0,
		},
        // 是否为红色
		isRed: {
			type: Boolean,
			default: false,
		},
		// 是否流动
		isFlow: {
			type: Boolean,
			default: false,
		},
		// 是否为虚线
		isDash: {
			type: Boolean,
			default: true,
		},
	},

	data() {
		return {};
	},
};
</script>

<style lang="less" scoped>
.lineBody {
	position: absolute;
	margin: 0;
	padding: 0;
	height: 2px;
	overflow: hidden;
}

.lineBody:hover {
	background: #00dcf3;
}

.lineBodyRed:hover {
	background: #ff0000 !important;
}

.noFlowBody {
	height: 100%;
	width: 100%;
	overflow: hidden;
	background: #00dcf3;
}
.noFlowBodyRed {
	height: 100%;
	width: 100%;
	overflow: hidden;
	background: #ff0000;
}

.dashFlowLine {
	width: 100%;
	height: 100%;
	background: repeating-linear-gradient(135deg, transparent, transparent 3px, #00dcf3 3px, #00dcf3 6px);
	animation: leftToRight 1s infinite linear;
	overflow: hidden;
}
.dashFlowLineRed {
	width: 100%;
	height: 100%;
	background: repeating-linear-gradient(135deg, transparent, transparent 3px, #ff0000 3px, #ff0000 6px);
	animation: leftToRight 1s infinite linear;
	overflow: hidden;
}

.dashNoflowLine {
	width: 100%;
	height: 100%;
	background: repeating-linear-gradient(135deg, transparent, transparent 3px, #00dcf3 3px, #00dcf3 6px);
	overflow: hidden;
}
.dashNoflowLineRed {
	width: 100%;
	height: 100%;
	background: repeating-linear-gradient(135deg, transparent, transparent 3px, #ff0000 3px, #ff0000 6px);
	overflow: hidden;
}

// 从右到左
@keyframes rightToLeft {
	0% {
		background-position: -1px -1px;
	}
	100% {
		background-position: -12px -12px;
	}
}
// 从左到右
@keyframes leftToRight {
	0% {
		background-position: -12px -12px;
	}
	100% {
		background-position: -1px -1px;
	}
}
</style>

相关文章:

  • 企业AI数据安全白皮书:深寻模型会话保护与安当TDE实战
  • 初识CMDB:数据质量的管理
  • 责任链模式:优雅处理复杂流程的设计艺术
  • 扩展------项目中集成阿里云短信服务
  • Android Studio 一直 Loading devices
  • C++:面向对象编程(续)
  • DeepSeek DeepEP学习(二)normal notify dispatch
  • 【开源宝藏】Spring Trace 一种轻量级的日志追踪新方式
  • 第三次CCF-CSP认证(含C++源码)
  • Redis数据结构深度解析:从String到Stream的奇幻之旅(一)
  • Clion快捷键、修改字体
  • 深度学习系列78:使用langchain的api进行RAG
  • 介绍exadata中的smart Scan技术
  • Java在小米SU7 Ultra汽车中的技术赋能
  • 回归预测 | Matlab实现GWO-BP-Adaboost基于灰狼算法优化BP神经网络结合Adaboost思想的回归预测
  • TDengine SQL手册—删除数据
  • Springboot中的VO、PO、DAO、BO、DTO、POJO
  • 测试周期紧张?功能与非功能测试的 5 个平衡策略
  • 数学建模笔记——层次分析法(AHP)
  • Qt信号与槽机制实现原理
  • 南宁哪里有做网站的公司/网游推广
  • weirdcore制作网站/自己怎么建网站
  • 党的建设 网站/搜索引擎快速排名推广
  • 三亚工商注册代办/石家庄百度推广优化排名
  • 潍坊专业网站制作公司营销/成都网站seo费用
  • wordpress 媒体库/东莞做网站seo