Progress 进度条

用于展示操作的当前进度。

代码示例

				
<template>
	<zk-theme type="page" :padding="30" showBack navbarTitle="LineProgress进度条">
		<!-- 基础用法 -->
		<zk-theme type="card" :padding="30" :radius="16" margin="0 0 30rpx 0">
			<zk-text type="secondary" :size="28" weight="bold" margin="0 0 20rpx 0" text="基础用法" align="center" />
			<zk-progress :percentage="50" />
		</zk-theme>

		<!-- 不显示百分比 -->
		<zk-theme type="card" :padding="30" :radius="16" margin="0 0 30rpx 0">
			<zk-text type="secondary" :size="28" weight="bold" margin="0 0 20rpx 0" text="不显示百分比" align="center" />
			<zk-progress :percentage="70" :show-text="false" />
		</zk-theme>

		<!-- 自定义颜色 -->
		<zk-theme type="card" :padding="30" :radius="16" margin="0 0 30rpx 0">
			<zk-text type="secondary" :size="28" weight="bold" margin="0 0 20rpx 0" text="自定义颜色" align="center" />
			<zk-progress :percentage="70" color="#FF5722" />
			<view class="margin-top">
				<zk-progress :percentage="80" color="#00C48F" />
			</view>
			<view class="margin-top">
				<zk-progress :percentage="90" color="#722ED1" />
			</view>
		</zk-theme>

		<!-- 自定义高度 -->
		<zk-theme type="card" :padding="30" :radius="16" margin="0 0 30rpx 0">
			<zk-text type="secondary" :size="28" weight="bold" margin="0 0 20rpx 0" text="自定义高度" align="center" />
			<zk-progress :percentage="40" :height="4" />
			<view class="margin-top">
				<zk-progress :percentage="40" :height="8" />
			</view>
			<view class="margin-top">
				<zk-progress :percentage="40" :height="12" />
			</view>
		</zk-theme>

		<!-- 条纹效果 -->
		<zk-theme type="card" :padding="30" :radius="16" margin="0 0 30rpx 0">
			<zk-text type="secondary" :size="28" weight="bold" margin="0 0 20rpx 0" text="条纹效果" align="center" />
			<zk-progress :percentage="60" stripe />
			<view class="margin-top">
				<zk-progress :percentage="60" stripe stripe-anim />
			</view>
		</zk-theme>

		<!-- 自定义文字 -->
		<zk-theme type="card" :padding="30" :radius="16" margin="0 0 30rpx 0">
			<zk-text type="secondary" :size="28" weight="bold" margin="0 0 20rpx 0" text="自定义文字" align="center" />
			<zk-progress :percentage="80" text-format="progress" />
			<view class="margin-top">
				<zk-progress :percentage="80" text-format="complete" />
			</view>
			<view class="margin-top">
				<zk-progress :percentage="80" text-format="number" />
			</view>
		</zk-theme>

		<!-- 动态进度 -->
		<zk-theme type="card" :padding="30" :radius="16" margin="0 0 30rpx 0">
			<zk-text type="secondary" :size="28" weight="bold" margin="0 0 20rpx 0" text="动态进度" align="center" />
			<zk-progress :percentage="dynamicValue" />
			<view class="button-group">
				<view class="button-wrapper">
					<zk-button text="-" type="primary" :disabled="dynamicValue <= 0" @click="decrease"
						margin="0 16rpx" />
				</view>
				<view class="button-wrapper">
					<zk-button text="+" type="primary" :disabled="dynamicValue >= 100" @click="increase"
						margin="0 16rpx" />
				</view>
			</view>
		</zk-theme>
	</zk-theme>
</template>

<script>
	export default {
		data() {
			return {
				dynamicValue: 30
			}
		},
		methods: {
			increase() {
				if (this.dynamicValue < 100) {
					this.dynamicValue = Math.min(100, this.dynamicValue + 10)
				}
			},
			decrease() {
				if (this.dynamicValue > 0) {
					this.dynamicValue = Math.max(0, this.dynamicValue - 10)
				}
			}
		}
	}
</script>

<style lang="scss">
	.margin-top {
		margin-top: 24rpx;
	}

	.button-group {
		margin-top: 24rpx;
		flex-direction: row;

		align-items: center;
		display: flex;
	}

	.button-wrapper {
		padding: 0 16rpx;
	}

	/* #ifdef APP-NVUE */
	.button-group {
		width: 662rpx;
	}

	/* #endif */
</style>
			

API

Props 属性

参数 说明 类型 默认值
percentage 百分比,范围0-100 number / string 0
height 进度条高度,单位rpx number / string 12
color 进度条颜色 string 主题色
backgroundColor 进度条背景色 string #dcdfe6
showText 是否显示进度文字 boolean true
textColor 进度文字颜色 string 同进度条颜色
textSize 进度文字大小,单位rpx number / string 28
stripe 是否显示条纹 boolean false
stripeAnim 是否开启条纹动画 boolean false
borderRadius 圆角大小,单位rpx number / string 100
textFormat 文字格式,可选值:percentage / progress / complete / number string percentage

文字格式说明

格式名称 显示效果 说明
percentage 70% 百分比形式
progress 进度:70% 带提示词的百分比
complete 完成70个 完成数量形式
number 70 纯数字形式