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

【Vue】使用html、css实现鱼骨组件

文章目录

  • 预览图
  • 组件
  • 测试案例

预览图

在这里插入图片描述

组件

<template><div class="context"><div class="top"><div class="label-context"><div class="label" v-for="(item, index) in value" :key="index"><div class="label-text" v-if="index % 2 === 0">{{ item.label }}</div><div class="connect-line-box" v-if="index % 2 === 0"><div class="connect-line"><i class="center-line-icon"></i></div></div></div></div></div><div class="center-line"><div class="icon-box" v-for="(item, index) in value" :key="index"><i class="center-line-icon"></i></div></div><div class="bottom"><div class="label-context"><div class="label" v-for="(item, index) in value" :key="index"><div class="connect-line-box" v-if="index % 2 === 1"><div class="connect-line"></div></div><div class="label-text" v-if="index % 2 === 1">{{ item.label }}</div></div></div></div></div>
</template>
<script>
export default {name: 'FishBoneComponent',props: {value: {type: Array,default: () => [{time: '2024-06-13 15:27:30',label: ''},{time: '2024-06-12 15:27:30',label: ''},{time: '2024-06-12 15:27:30',label: ''},{time: '2024-06-12 15:27:30',label: ''},{time: '2024-06-12 15:27:30',label: ''},{time: '2024-06-12 15:27:30',label: ''},{time: '2024-06-12 15:27:30',label: ''},{time: '2024-06-12 15:27:30',label: ''},{time: '2024-06-12 15:27:30',label: ''},{time: '2024-06-12 15:27:30',label: ''},]}},mounted() {this.value = this.value.sort((a, b) => {return new Date(a.time) - new Date(b.time);});console.log(this.value)}
}
</script>
<style lang="scss" scoped>
$center-color: #1890ff;
$text-box-width: 200px;
$text-margin-left: 10px;
$line-height: 40px;
$add-width: 0px;
$line-icon-size: 13px;.context {width: 100%;padding: 0.5%;height: 100%;
}.center-line {position: absolute;height: 2px;background-color: $center-color;width: 98%;display: flex;align-items: center;justify-content: left;
}.center-line::after {content: '';position: absolute;top: 50%;right: -10px;width: 0;height: 0;border-top: 5px solid transparent;border-bottom: 5px solid transparent;border-left: 10px solid $center-color;transform: translateY(-50%);
}.center-line .icon-box:first-child {margin-left: $text-margin-left;width: $text-box-width/2 + $line-icon-size/2;flex-shrink: 0;i {float: right;width: $line-icon-size;height: $line-icon-size;flex-shrink: 0;}
}.center-line .icon-box:not(:first-child) {margin-left: $text-margin-left - $line-icon-size/2;width: $text-box-width/2 + $line-icon-size/2;flex-shrink: 0;i {float: right;width: $line-icon-size;height: $line-icon-size;flex-shrink: 0;}
}.center-line-icon {width: $line-icon-size;height: $line-icon-size;background-color: $center-color;border-radius: 50%;
}.top .label-context {display: flex;flex-direction: row;justify-content: normal;
}.connect-line-box {display: flex;flex-direction: row;text-align: center;justify-content: center;
}.connect-line {width: 2px;height: $line-height;background-color: #1d71fa;
}.top .label {display: flex;flex-direction: column;justify-content: flex-end;margin-left: $text-margin-left;
}.label > div {width: $text-box-width;margin-left: $add-width;white-space: normal;
}.bottom .label-context {display: flex;flex-direction: row;justify-content: normal;margin-left: $text-box-width/2;
}.bottom .label {display: flex;flex-direction: column;justify-content: flex-start;margin-left: $text-margin-left;
}.label-text {padding: 6px;background-color: rgb($center-color, 0.08);border-radius: 3px;color: black;font-size: 15px;
}
</style>

测试案例

<template><div class="card"><FishBoneComponent :value="data"></FishBoneComponent></div>
</template><script>
import FishBoneComponent from "@/views/FishBoneComponent";export default {name: "FishBone",components: {FishBoneComponent},data(){return{data: [{time: '2024-06-13 15:27:30',label: '测试测试测试测试测试测试测试测试测试'},{time: '2024-06-12 15:27:30',label: '测试测试测试测试测试测试测试测试测试测试'},{time: '2024-06-12 15:27:30',label: '测试测试测试测试测试测试测试测试测试测试测试测试'},{time: '2024-06-12 15:27:30',label: '测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试'},{time: '2024-06-12 15:27:30',label: '测试测试测试测试测试测试测试测试测试测试测试测试测试'},{time: '2024-06-12 15:27:30',label: '测试'},{time: '2024-06-12 15:27:30',label: '测试'},{time: '2024-06-12 15:27:30',label: '测试'},{time: '2024-06-12 15:27:30',label: '测试'},{time: '2024-06-12 15:27:30',label: '测试'},]}}
}
</script><style scoped>
.card{padding: 8px;
}.title-box{margin-bottom: 8px;
}.title{font-size: 18px;font-weight: bold;color: #1890ff;
}
</style></style>
http://www.lryc.cn/news/394811.html

相关文章:

  • Python的多态
  • 001uboot体验
  • Flask之电子邮件
  • Vue 2 与 ECharts:结合使用实现动态数据可视化
  • .net core Redis 使用有序集合实现延迟队列
  • linux 安装Openjdk1.8
  • 鸿蒙系统:未来智能生态的引领者
  • Java语言程序设计——篇二(1)
  • 水果商城系统 SpringBoot+Vue
  • 半导体制造企业 文件共享存储应用
  • 深入分析 Android BroadcastReceiver (九)
  • 从数据到洞察:DataOps加速AI模型开发的秘密实践大公开!
  • 全景图三维3D模型VR全景上传展示H5开发
  • 前端面试题29(js闭包和主要用途)
  • 使用Keil 点亮LED灯 F103ZET6
  • 流批一体计算引擎-12-[Flink]旁路输出getSideOutput(OutputTag)实现拆分流和复制流
  • 【Scrapy】 Scrapy 爬虫框架
  • 【笔记】太久不用redis忘记怎么后台登陆了
  • 昇思25天打卡营-mindspore-ML- Day14-VisionTransformer图像分类
  • 微信环境内H5网页,用开放标签wx-open-launch-app打开app
  • 【c++基础】高精度数不进位加法
  • UniApp 中 Web/H5 正确使用反向代理解决跨域问题
  • Redis Stream:实时数据流的处理与存储
  • 【论文阅读】-- Visual Traffic Jam Analysis Based on Trajectory Data
  • 修改编译依赖openssl的libcrypto.so
  • ����: �Ҳ������޷��������� javafx.fxml ԭ��: java.lang.ClassNotFoundException解决方法
  • 【C++】———— 继承
  • Python人生重开器
  • python 高级技巧 0708
  • HOW - React Router v6.x Feature 实践(react-router-dom)