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 分钟前
【Redis】Redis常用命令速查表(完整版)
java·前端·数据库·redis·后端·spring·缓存
Csvn6 分钟前
状态管理方案对比(Context、Zustand、Jotai 选型指南)
前端
Irene19917 分钟前
JavaScript 事件循环(Event Loop) 的运作流程(附:queueMicrotask() 将一个回调函数立即排队到微任务队列中)
javascript·事件循环·宏任务·微任务·调用栈·queuemicrotask
snow_yan7 分钟前
基于 json-render 的流式表单渲染方案
前端·react.js·llm
wobi_baoyan9 分钟前
【已解决】使用Maven打包发生或者启动Spring Boot项目发生 错误: 不支持发行版本 17
服务器·前端·javascript
Dylan~~~9 分钟前
Go语言Web框架选型指南:从入门到精通
开发语言·前端·golang
学以智用11 分钟前
# TypeScript 高级特性(核心+实用)
前端·javascript·typescript
学以智用12 分钟前
TypeScript 核心基础:类型/变量 + 函数 + 接口
前端·javascript·typescript
SuperEugene15 分钟前
Vue3 组件解耦实战:Props/Emit/ 事件总线用法 + 避坑指南|Vue 组件与模板规范篇
前端·javascript·vue.js
Cache技术分享21 分钟前
360. Java IO API - 访问文件系统
前端·后端