ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

基于Vue的标尺插件(刻度尺)

2021-06-09 10:30:07  阅读:202  来源: 互联网

标签:插件 Vue color content width right faReData 5% 刻度尺


可根据高和宽度自适应,主要传值为宽度和距离零刻度的距离,代码和图片如下。
在这里插入图片描述

 <template>
	<div class="demoRule">
		<el-row class=" main">
			<div class="rightBorder" v-if="duiData&&duiData.length>0"></div>
			<div class="ruleF" v-for="(item,indexDui) in duiData" :key="indexDui" :style="{'height':(duiData&&duiData.length>0)?(100/duiData.length)+'%':'100%'}">
				<div class="content" :style="{'border-top':(indexDui==0?'1.5px solid #9c9c9c':'')}">
					<div class="faRe" v-for="(itemF,indexF) in item.faReData" :key="indexF" :style="{'right':itemF.right}"> (发热)</div>
					<div class="boxes" v-for="(itemDuo,indexDuo) in item.duoData" :key="indexDuo" :style="{'width':itemDuo.width,'right':itemDuo.right,'background':colorData[itemDuo.color],}">{{itemDuo.content}} </div>
				</div>
				<div v-for="(itemNum, indexNum) in 24 " :key="indexNum" class="ruleBody" :style="{'margin-right':(indexNum==0?'2%':'')}">
					<div class="num" v-if="indexDui%2==0">{{itemNum*50}}</div>
				</div>
			</div>
		</el-row>
	</div>
</template>
<script>

export default {
	data () {
		return {
			colorData: {
				1: "#aad494",
				2: "#aab6dc",
				3: "#faf5b3",
				4: "#c5acd3",
				5: "#faa5a5",
				6: "#faacc4",
			},
			duiData: [
				{
					duoData: [
						{
							width: "5%",
							right: "0%",
							color: "1",
							content: "爽肤水",
						},
						{
							width: "8%",
							right: "26%",
							color: "2",
							content: "康师傅",
						}, {
							width: "6%",
							right: "75%",
							color: "3",
							content: "电风扇",
						}
					],
					faReData: [
						{ right: "3%", },
						{ right: "36%", },
						{ right: "86%", }
					],
				},
				{
					duoData: [
						{
							width: "3%",
							right: "25%",
							color: "4",
							content: "娃哈哈",
						},
						{
							width: "7%",
							right: "56%",
							color: "5",
							content: "集装箱",
						}, {
							width: "7%",
							right: "85%",
							color: "6",
							content: "意大利炮",
						}
					],
					faReData: [
						{ right: "5%", },
						{ right: "66%", },
						{ right: "76%", }
					],
				},
				{
					duoData: [
						{
							width: "5%",
							right: "5%",
							color: "1",
							content: "爽肤水",
						},
						{
							width: "8%",
							right: "26%",
							color: "2",
							content: "康师傅",
						}, {
							width: "6%",
							right: "75%",
							color: "3",
							content: "电风扇",
						}
					],
					faReData: [
						{ right: "3%", },
						{ right: "36%", },
						{ right: "86%", }
					],
				},
				{
					duoData: [
						{
							width: "3%",
							right: "25%",
							color: "4",
							content: "娃哈哈",
						},
						{
							width: "7%",
							right: "56%",
							color: "5",
							content: "集装箱",
						}, {
							width: "7%",
							right: "85%",
							color: "6",
							content: "意大利炮",
						}
					],
					faReData: [
						{ right: "5%", },
						{ right: "66%", },
						{ right: "76%", }
					],
				},
				{
					duoData: [
						{
							width: "5%",
							right: "5%",
							color: "1",
							content: "爽肤水",
						},
						{
							width: "8%",
							right: "26%",
							color: "2",
							content: "康师傅",
						}, {
							width: "6%",
							right: "75%",
							color: "3",
							content: "电风扇",
						}
					],
					faReData: [
						{ right: "3%", },
						{ right: "36%", },
						{ right: "86%", }
					],
				},
				{
					duoData: [
						{
							width: "3%",
							right: "25%",
							color: "4",
							content: "娃哈哈",
						},
						{
							width: "7%",
							right: "56%",
							color: "5",
							content: "集装箱",
						}, {
							width: "7%",
							right: "85%",
							color: "6",
							content: "意大利炮",
						}
					],
					faReData: [
						{ right: "5%", },
						{ right: "66%", },
						{ right: "76%", }
					],
				},
				{
					duoData: [
						{
							width: "5%",
							right: "5%",
							color: "1",
							content: "爽肤水",
						},
						{
							width: "8%",
							right: "26%",
							color: "2",
							content: "康师傅",
						}, {
							width: "6%",
							right: "75%",
							color: "3",
							content: "电风扇",
						}
					],
					faReData: [
						{ right: "3%", },
						{ right: "36%", },
						{ right: "86%", }
					],
				},
				{
					duoData: [
						{
							width: "3%",
							right: "25%",
							color: "4",
							content: "娃哈哈",
						},
						{
							width: "7%",
							right: "56%",
							color: "5",
							content: "集装箱",
						}, {
							width: "7%",
							right: "85%",
							color: "6",
							content: "意大利炮",
						}
					],
					faReData: [
						{ right: "5%", },
						{ right: "66%", },
						{ right: "76%", }
					],
				},
			],

		};
	},
	watch: {},
	created () {

	},
	mounted () {
		// ruleF	
	},
	methods: {}
};
</script>
<style lang="scss" scoped>
.demoRule {
	width: calc(100% - 30px);
	height: calc(100vh - 131px);
	background: #f3f3f3;
	padding: 15px;
}
.main {
	width: 95%;
	height: 95%;
	margin: 0px auto;
	margin-top: 1%;
	padding: 10px;
	border: 1px solid #eaeaea;
	position: relative;
	// background: white;
}
.rightBorder {
	position: absolute;
	width: 1.5px;
	height: calc(100% - 20px);
	background: #c3c3c3;
	top: 10px;
	right: calc(2% + 7px);
	z-index: 100;
}

.ruleF {
	width: 100%;
	font-size: 12px;
	color: #909399;
}
.content {
	overflow: hidden;
	position: relative;
	width: 96%;
	margin-left: 2%;
	height: calc(100% - 30px);
	border-left: 1.5px solid #777777;
	background: #ffffff;
	// border-right: 1.5px solid #777777;
}
.faRe {
	z-index: 101;
	position: absolute;
	color: red;
	top: 5px;
}
.boxes {
	z-index: 1;
	height: 100%;
	position: absolute;
	top: 0px;
	color: #0a2731;
	justify-content: center;
	align-items: center;
	text-align: center;
	display: flex;
	font-weight: bold;
}
.ruleBody {
	width: 4%;
	height: 30px;
	background: url("../../assets/images/rule.png");
	background-repeat: no-repeat;
	background-size: 100% 100%;
	float: right;
}
.num {
	position: relative;
	margin-left: -10px;
	z-index: 100;
	margin-top: 13px;
}
</style>

标签:插件,Vue,color,content,width,right,faReData,5%,刻度尺
来源: https://blog.csdn.net/qq_42872836/article/details/117732880

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有