uniapp中使用封装步骤条组件

针对步骤条封装完终于清清楚楚啦

先看效果:

附上代码:使用可直接复用:数据是写在了当前组件中,如有必须,可以使用其中的props传值stepInfos传递相应的数据,根据steps步数就可以控制走到哪一步啦

复制代码
<template>
	<view class="step-bar">
		<view class="step_item" v-for="(item,index) in stepInfo.list" :key="item.id">
			<view :class="stepInfo.step >= index+1 ? 'circle circle-active':'circle'"></view>
			<view :class="stepInfo.step >= index+2 ? 'line line-active':'line'" v-if="index!==stepInfo.list.length-1">
			</view>
			<view class="middle-box">
				<text
					:class="stepInfo.step < index+1 ? 'text1-actived':stepInfo.step == index+1?'text1-active':text1">{{item.name}}</text>
				<text class="text2">{{item.time}}</text>
			</view>
			<view class="status_text"
				:class="stepInfo.step < index+1 ? 'text1-actived':stepInfo.step == index+1?'text1-active':text1">
				{{item.status}}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			// 传递步骤参数
			stepInfo: {
				type: Object,
				default: function() {
					return {
						list: [],
						step: 0
					}
				}
			}

		},
		data() {
			return {
				stepInfo: {
					step: 3,
					list: [{
						id: 1,
						name: '发起充值',
						time: '2020-12-12 12:47:56',
						status: '已完成'
					}, {
						id: 2,
						name: '处理中',
						time: '2020-12-12 12:47:56',
						status: '进行中'
					}, {
						id: 3,
						name: '到账成功',
						time: '2020-12-12 12:47:56',
						status: '未开始'
					}]
				}
			}
		},
	}
</script>

<style lang="scss" scoped>
	.step_item {
		position: relative;
		height: 144rpx;
		display: flex;

		.line {
			position: absolute;
			top: 40rpx;
			left: 8rpx;
			content: "";
			width: 4rpx;
			height: 100rpx;
			background-color: #E6E8EF;
		}

		.line-active {
			background-color: #FF2B46;
		}
	}

	.circle {
		width: 20rpx;
		height: 20rpx;
		margin-right: 40rpx;
		margin-top: 10rpx;
		border-radius: 50%;
		background-color: #E6E8EF;
	}

	.circle-active {
		background-color: #FF2B46;
	}

	.middle-box {
		display: flex;
		flex-direction: column;

		.text2 {
			color: #999999;
			font-size: 24rpx;
		}
	}


	.text1 {
		color: #666666;
		font-size: 28rpx;
	}

	.text1-active {
		color: #FF2B46;
	}

	.text1-actived {
		color: #333333;
	}

	.status_text {
		flex-grow: 1;
		display: flex;
		justify-content: flex-end;
		font-size: 28rpx;
	}


	.status_text_active {
		// color: #FF2B46;
	}
</style>
相关推荐
abigale0319 分钟前
webpack+vite前端构建工具 -11实战中的配置技巧
前端·webpack·node.js
专注API从业者39 分钟前
构建淘宝评论监控系统:API 接口开发与实时数据采集教程
大数据·前端·数据库·oracle
Joker`s smile42 分钟前
Chrome安装老版本、不同版本,自制便携版本用于前端调试
前端·chrome
weixin_416639971 小时前
爬虫工程师Chrome开发者工具简单介绍
前端·chrome·爬虫
我是如子啊1 小时前
【解决“此扩展可能损坏”】Edge浏览器(chrome系列通杀))扩展损坏?一招保留数据快速修复
前端·chrome·edge
灵性花火1 小时前
Qt的前端和后端过于耦合(0/7)
开发语言·前端·qt
孤水寒月5 小时前
基于HTML的悬窗可拖动记事本
前端·css·html
祝余呀5 小时前
html初学者第一天
前端·html
脑袋大大的6 小时前
JavaScript 性能优化实战:减少 DOM 操作引发的重排与重绘
开发语言·javascript·性能优化
速易达网络7 小时前
RuoYi、Vue CLI 和 uni-app 结合构建跨端全家桶方案
javascript·vue.js·低代码