先看效果图
template部分
<div class="g-steps">
<div class="steps-list" v-if="steps.length">
<div class="step-item flex align-items-center" v-for="(item, index) in steps">
<span>{{ index + 1 }}</span>
<div class="content">
<p class="title">{{ item.title }}</p>
<p class="time">{{ item.lastModifiedAt }}</p>
</div>
</div>
</div>
</div>
js部分
<script setup lang="ts">
import { formatDate } from '@/utils/common';
type Props = {
steps: {
title: string,
lastModifiedAt: string
}[]
}
const props = defineProps<Props>()
</script>
style部分
<style scoped lang="scss">
.g-steps {
.steps-list {
.step-item {
position: relative;
&::before {
content: '';
position: absolute;
height: 100%;
top: 50%;
left: 10px;
width: 1px;
background-color: rgba(0, 0, 0, 0.12);
z-index: -1;
}
&:last-child {
&::before {
content: none;
}
}
span {
display: inline-block;
background-color: #9e9d9e;
width: 22px;
height: 22px;
border-radius: 50%;
text-align: center;
color: white;
line-height: 22px;
}
.content {
margin-left: 12px;
margin-top: 8px;
padding: 8px;
width: 100%;
background-color: #F9F9F9;
p {
line-height: 24px;
}
p.time {
color: #B8B8B8;
font-size: 12px;
}
}
}
}
.p-steps {
:deep(.p-steps-list) {
flex-direction: column;
li {
&::before {
background-color: rgba(0, 0, 0, 0.12);
height: 100%;
left: 18px;
top: 18px;
width: 1px;
}
}
.p-steps-item {
&::before {
position: absolute;
}
}
}
}
}
</style>