Vue 使用html、css實(shí)現(xiàn)魚骨組件圖
預(yù)覽圖
組件
<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>
測(cè)試案例
<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: '測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試' }, { time: '2024-06-12 15:27:30', label: '測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試' }, { time: '2024-06-12 15:27:30', label: '測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試' }, { time: '2024-06-12 15:27:30', label: '測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試' }, { time: '2024-06-12 15:27:30', label: '測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試測(cè)試' }, { time: '2024-06-12 15:27:30', label: '測(cè)試' }, { time: '2024-06-12 15:27:30', label: '測(cè)試' }, { time: '2024-06-12 15:27:30', label: '測(cè)試' }, { time: '2024-06-12 15:27:30', label: '測(cè)試' }, { time: '2024-06-12 15:27:30', label: '測(cè)試' }, ] } } } </script> <style scoped> .card{ padding: 8px; } .title-box{ margin-bottom: 8px; } .title{ font-size: 18px; font-weight: bold; color: #1890ff; } </style> </style>
到此這篇關(guān)于Vue 使用html、css實(shí)現(xiàn)魚骨組件的文章就介紹到這了,更多相關(guān)Vue 魚骨組件內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
京東 Vue3 組件庫(kù)支持小程序開發(fā)的詳細(xì)流程
這篇文章主要介紹了京東 Vue3 組件庫(kù)支持小程序開發(fā)的詳細(xì)流程,通過引入NutUI,即可在項(xiàng)目中使用,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-06-06vue 中Virtual Dom被創(chuàng)建的方法
本文將通過解讀render函數(shù)的源碼,來分析vue中的vNode是如何創(chuàng)建的,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-04-04結(jié)合mint-ui移動(dòng)端下拉加載實(shí)踐方法總結(jié)
下面小編就為大家?guī)硪黄Y(jié)合mint-ui移動(dòng)端下拉加載實(shí)踐方法總結(jié)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-11-11vue常用指令實(shí)現(xiàn)學(xué)生錄入系統(tǒng)的實(shí)戰(zhàn)
本文主要介紹了vue常用指令實(shí)現(xiàn)學(xué)生錄入系統(tǒng)的實(shí)戰(zhàn),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-02-02vue引用BootStrap以及引用bootStrap-vue.js問題
這篇文章主要介紹了vue引用BootStrap以及引用bootStrap-vue.js問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-10-10使用ElementUI修改el-tabs標(biāo)簽頁(yè)組件樣式
這篇文章主要介紹了使用ElementUI修改el-tabs標(biāo)簽頁(yè)組件樣式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08