uniapp自定义进度条组件

目标效果

原型设计为这样的样式,但是现有的进度条组件样式都无法满足需求,于是编写组件实现。

设计引用格式为

html 复制代码
<zLineProgress :total="15" :val="7" title="你好吗" />

定义组件

html 复制代码
<template>
	<view style="height: 3.5rem; margin: 0 1em;">
		<view class="line-total" :style="'width: ' + (val / total * 100) + '%'">{{val}}</view>
		<view style="position: relative;">			
			<view class="line-base"></view>
			<view class="line-blue" :style="'width: ' + (val / total * 100) + '%'"></view>
		</view>
		<view class="line-val">
			<text>{{title}}</text>
			<text>{{total}}</text>
		</view>
	</view>
</template>

<script>
export default {
	name: 'zLineProgress',
	data() {
		return {
		}
	},
	props: {
	    // 标题
	    title: {
	        type: [String, Number],
	        default: ''
	    },
	    total: {
			type: [Number],
			default: 0
		},
		val: {
			type: [Number],
			default: 0
		}
	},
	computed: {
		
	},
	methods: {
		
	}
}
</script>

<style scoped>
.line-total {
	color: #FFB000;
	text-align: right;
	font-size: 25rpx;
	font-style: normal;
	font-weight: 700;
	line-height: normal;
}
.line-base {
	position: absolute;
	width: 100%;
	height: 3px;
	border-radius: 8px;
	background: rgba(128, 136, 142, 0.40);
}
.line-blue {
	position: absolute;
	width: 50%;
	height: 4px;
	border-radius: 8px;
	background: #1677FF;
	box-shadow: 0px 0px 4px 0px rgba(22, 119, 255, 0.50);
}
.line-val {
	display: flex;
	justify-content: space-between;
	color: #7e7e7e;
	font-size: 25rpx;
	font-weight: 50px;
	margin-top: 12rpx;
}
</style>

页面导入

js 复制代码
import zLineProgress from '../../uni_modules/z-line-progress.vue'

配置组件声明

bash 复制代码
components: {
	"zLineProgress": zLineProgress
},

然后如本文开头所示使用即可

相关推荐
不听话坏2 小时前
Ignition篇(下 一) 动态执行前的事情
开发语言·前端·javascript
likeyi072 小时前
require 和 import的区别
开发语言·前端
pany2 小时前
做 AI 友好的开源 Vue3 模板 🌈
前端·vue.js·ai编程
小二·3 小时前
React 19 + Next.js 15 现代前端开发实战:App Router / Server Components / 流式渲染
前端·javascript·react.js
谙忆10244 小时前
前端图片直传对象存储:OSS/S3 预签名 URL、STS 临时凭证与回调校验
前端
CHNE_TAO_EMSM5 小时前
Android studio 打开文件时自动下载源码
前端·javascript·android studio
一孤程6 小时前
Airtest自动化测试第五篇:小程序与Web测试——跨平台自动化全覆盖
前端·自动化测试·小程序·自动化·测试·airtest
IT_陈寒6 小时前
SpringBoot自动配置不是你以为的那样的智能
前端·人工智能·后端
yume_sibai7 小时前
大屏数据可视化 - 边框红绿呼吸灯实现详解
前端·信息可视化·typescript
竹林8187 小时前
从 ethers.js 迁移到 Viem:一个签名验证 Bug 让我彻底放弃旧爱
javascript