uniapp自定义步骤条(可二开进行调试)

前言

有一个业务需求是需要一个步骤条,但是发现开源的都不太合适,所以就自己写了一个。

开始

test.vue

<template>
	<view class="authenticateRecordDetails_container">
		<!-- 进度 -->
		<view class="authenticateStep_content">
			<view class="title_content"><text class="text_default" style="font-size: 32rpx; font-weight: bold;">鉴定进度</text></view>
			
			<view class="step_content">
				<view class="left">
					<view class="circle circle_succ">
						<image src="/static/images/jianbao/step/1.png" mode=""></image>
					</view>
					<view class="line line_succ"></view>
				</view>
				<view class="right">
					<view class="card_content" style="padding: 80rpx 0;">
						<text>卡片内容</text>
					</view>
				</view>
			</view>
			
			<view class="step_content">
				<view class="left">
					<view class="circle circle_defult">
						<image src="/static/images/jianbao/step/1.png" mode=""></image>
					</view>
					<view class="line circle_defult"></view>
				</view>
				<view class="right">
					<view class="card_content" style="padding: 40rpx 0;">
						<text>卡片内容</text>
					</view>
				</view>
			</view>
			
			<view class="step_content">
				<view class="left">
					<view class="circle circle_defult">
						<image src="/static/images/jianbao/step/1.png" mode=""></image>
					</view>
				</view>
				<view class="right">
					<view class="card_content" style="padding: 40rpx 0;">
						<text>卡片内容</text>
					</view>
				</view>
			</view>
			
			
			
		</view>
		<!-- 进度end -->
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
			}
		},
		components: {},
		
		onLoad(options) {},
		onShow() {},
		methods: {
			
		}
	}
</script>

<style scoped lang="scss">
	.authenticateRecordDetails_container {
		margin: 20rpx 20rpx;
		// 鉴定进度
		.authenticateStep_content {
			margin-top: 40rpx;
			.title_content {
				margin-bottom: 40rpx;
			}
			.step_content {
				display: flex;
				// justify-content: flex-start;
				// align-items: center;
				.left {
					width: 70rpx;
					// background-color: blue;
					.circle {
						width: 70rpx;
						height: 70rpx;
						line-height: 80rpx;
						text-align: center;
						border-radius: 100%;
						image {
							width: 34rpx;
							height: 34rpx;
						}
					}
					.circle_succ {
						background-color: #1F5491;
					}
					.circle_defult {
						background-color: #CECECE;
					}
					.line {
						width: 4rpx;
						height: calc(100% - 70rpx);
						margin: 0 auto;
						background-color: #bbb;
					}
					.line_succ {
						background-color: #1F5491;
					}
					.line_defult {
						background-color: #bbb;
					}
				}
				.right {
					flex: 1;
					margin-bottom: 80rpx;
					margin-left: 20rpx;
					.card_content {
						width: 100%;
						position: relative;
						top: -10rpx;
						background-color: #fff;
						box-shadow: 0rpx 4rpx 8rpx 0rpx; 
						border-radius: 8rpx;
					}
				}
			}
		}
	}
</style>

总结

可把它进行封装成组件

UniApp 是一个基于 Vue.js 的跨平台框架,可以用于发多个平台的应用程序。如果你想要自定义竖向的步骤条,可以通过使用 Vue.js 和 CSS 来实现。 首先,你可以创建一个组件来表示每个步骤,例如 Step.vue: ```vue <template> <div :class="{'step': true, 'active': isActive}">{{ index }}</div> </template> <script> export default { props: { index: { type: Number, required: true }, isActive: { type: Boolean, default: false } } } </script> <style scoped> .step { width: 50px; height: 50px; border-radius: 50%; line-height: 50px; text-align: center; background-color: #ccc; } .active { background-color: #ff0000; color: #fff; } </style> ``` 然后,在你的页面中使用这个组件来创建竖向的步骤条,例如 Steps.vue: ```vue <template> <div class="steps"> <step v-for="(step, index) in steps" :key="index" :index="index + 1" :is-active="currentStep === index + 1" /> </div> </template> <script> import Step from '@/components/Step.vue' export default { components: { Step }, data() { return { steps: ['Step 1', 'Step 2', 'Step 3'], currentStep: 1 } } } </script> <style scoped> .steps { display: flex; flex-direction: column; } </style> ``` 在上面的例子中,使用了一个数组来定义步骤的文本内容,然后通过 v-for 指令和 Step 组件来渲染每个步骤。通过给 Step 组件传递 `:is-active` 属性来判断当前步骤是否为激活状态。 这样,你就可以在 UniApp自定义竖向的步骤条了。根据你的需要,你可以根据具体的样式要求进行调整和扩展。希望对你有所帮助!如果你对这方面还有其他问题,可以继续问我。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

An_s

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值