[Vue3]简易时间轴组件
<template>
<div ref="container" class="timeline-container">
<div class="plan-box">
<span class="plan-title">计划span>
<div class="plan-timeline">
<div v-for="(node, index) in nodeList" :key="index" class="timeline-item">
<p>{{ node.name }}p>
<p>{{ node.time }}p>
<div class="item-node">div>
div>
<div class="timeline-item end-item">
<div class="item-node">div>
div>
<div class="plan-timeline-progress">div>
div>
div>
<div class="actual-box">
<span class="actual-title">实际span>
<div class="actual-timeline">
<div class="actual-timeline-progress">div>
<div v-for="(node, index) in nodeList" :key="index" class="timeline-item">
<div class="item-node">div>
<p>{{ node.time }}p>
<p>{{ node.name }}p>
div>
<div class="timeline-item end-item">
<div class="item-node">div>
div>
div>
div>
div>
template>
<script setup>
import { toRefs } from 'vue';
const props = defineProps({
planStartTime: {
type: String,
default: '2021-05-01'
},
planEndTime: {
type: String,
default: '2022-05-01'
},
actualStartTime: {
type: String,
default: '2021-05-01'
},
actualEndTime: {
type: String,
default: '2022-05-01'
},
nodeList: {
type: Array,
default: [
{
name: 'DVT',
time: '2021-05-01'
},
{
name: 'T版',
time: '2021-08-01'
},
{
name: 'DVT样机评审(全功能样机)',
time: '2022-02-01'
}
]
}
});
const { planStartTime, planEndTime, actualEndTime, actualStartTime, nodeList } = toRefs(props);
script>
<style lang="less" scoped>
//@cbackground: #f1f8ffb3;
//@borderColor: #f2f6fc54;
@mainColor: #3cca64;
// -------------------------------公共样式--------------------------------------
.timeline-container {
//border: 1px solid black;
padding: 10px;
overflow: auto;
margin-top: 20px;
}
// 时间轴上的圆点样式
.item-node {
width: 15px;
height: 15px;
position: absolute;
left: 0;
border-radius: 50%;
border: 4px solid @mainColor;
background: white;
}
.end-item {
padding: 0 !important;
border: 0 !important;
margin: 0 !important;
width: 0 !important;
}
// -------------------------------计划部分样式-----------------------------------
.plan-box {
display: flex;
justify-content: flex-start;
align-items: center;
}
.plan-title {
display: inline-block;
padding: 20px 10px;
border: 1px solid black;
background: @mainColor;
color: white;
font-weight: bold;
}
.plan-timeline {
transform: translateY(-25%);
padding: 10px;
//border: 1px solid black;
display: inline-block;
.plan-timeline-progress {
width: 100%;
height: 6px;
background: @mainColor;
}
.timeline-item {
height: 50px;
}
.item-node {
transform: translate(-50%, 75%);
bottom: 0;
}
}
// ----------------------------------实际部分样式-----------------------------
.actual-box {
display: flex;
justify-content: flex-start;
align-items: center;
}
.actual-title {
display: inline-block;
padding: 20px 10px;
border: 1px solid black;
background: @mainColor;
color: white;
font-weight: bold;
}
.actual-timeline {
padding: 10px;
//border: 1px solid black;
display: inline-block;
transform: translateY(25%);
.actual-timeline-progress {
width: 100%;
height: 6px;
background: @mainColor;
}
.timeline-item {
height: 50px;
}
.item-node {
top: 0;
transform: translate(-50%, -75%);
}
}
// 时间轴上一个item的样式
.timeline-item {
display: inline-block;
//border: 1px solid black;
vertical-align: top;
margin-right: 10px;
//margin-bottom: 10px;
//overflow: hidden;
padding: 10px 15px 0;
//text-align: center;
position: relative;
font-size: 14px;
//height: 50px;
//background: @mainColor;
//color: white;
font-weight: bold;
}
style>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216