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
},

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

相关推荐
0思必得010 分钟前
[Web自动化] Selenium处理滚动条
前端·爬虫·python·selenium·自动化
Misnice12 分钟前
Webpack、Vite、Rsbuild区别
前端·webpack·node.js
青茶36013 分钟前
php怎么实现订单接口状态轮询(二)
前端·php·接口
大橙子额1 小时前
【解决报错】Cannot assign to read only property ‘exports‘ of object ‘#<Object>‘
前端·javascript·vue.js
WooaiJava2 小时前
AI 智能助手项目面试技术要点总结(前端部分)
javascript·大模型·html5
爱喝白开水a2 小时前
前端AI自动化测试:brower-use调研让大模型帮你做网页交互与测试
前端·人工智能·大模型·prompt·交互·agent·rag
Never_Satisfied2 小时前
在JavaScript / HTML中,关于querySelectorAll方法
开发语言·javascript·html
董世昌412 小时前
深度解析ES6 Set与Map:相同点、核心差异及实战选型
前端·javascript·es6
WeiXiao_Hyy3 小时前
成为 Top 1% 的工程师
java·开发语言·javascript·经验分享·后端
吃杠碰小鸡4 小时前
高中数学-数列-导数证明
前端·数学·算法