# t-progress-line
ProgressLine 线形进度
t-progress-line 组件介绍
线型进度条组件可以直观地展示进度百分比,适用于多种场景,如加载指示器、任务完成度展示等。
t-progress-line 平台兼容
| Harmony | H5 | Android | iOS | 小程序 | UTS |
|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
t-progress-line 基础用法
基础用法参考 demo/progress-line/progress-line.uvue,支持主题、百分比、宽度与自定义颜色配置。
vue
<template>
<view class="p-15">
<tui-theme-switch></tui-theme-switch>
<t-card class='mb-15'
title="ProgressLine 线形进度条"
sub-title='组件以直观的视觉方式展示进度百分比,支持自定义颜色、显示比例文本.'></t-card>
<t-section title="操作"
class="mb-15"></t-section>
<t-row class="r-10 p-10 mb-15">
<t-button type="primary"
class="mr-7 f"
@click="increase">增加</t-button>
<t-button type="warning"
class="f"
@click="reduce">减少</t-button>
</t-row>
<template v-if="area==1">
<t-section title="基础功能+主题展示"
class="mb-15"></t-section>
<t-col class="r-10 p-10 mb-15">
<t-progress-line class="mb-12"
:percent="percent"
type="info"></t-progress-line>
<t-progress-line class="mb-12 h-75 r-75"
:percent="percent"
type="success"></t-progress-line>
<t-progress-line class="mb-12"
:percent="percent"
type="error"></t-progress-line>
<t-progress-line class="mb-12"
:percent="percent"
type="primary"></t-progress-line>
<t-progress-line :percent="percent"
type="warning"></t-progress-line>
</t-col>
</template>
<template v-if="area==2">
<t-section title="显示百分比"
class="mb-15"></t-section>
<t-row class="faic">
<t-progress-line class="f mr-5"
:percent="percent"
type="success"></t-progress-line>
<t-text>{{percent}}%</t-text>
</t-row>
</template>
<template v-if="area==3">
<t-section title="显示百分比"
class="mb-15"></t-section>
<t-col>
<t-progress-line class="mb-12"
:showPercentage="true"
:percent="percent"
type="info"></t-progress-line>
<t-progress-line class="mb-12"
:showPercentage="true"
:percent="percent"
type="success"></t-progress-line>
<t-progress-line class="mb-12"
:showPercentage="true"
:percent="percent"
type="error"></t-progress-line>
<t-progress-line class="mb-12"
:showPercentage="true"
:percent="percent"
type="primary"></t-progress-line>
<t-progress-line :showPercentage="true"
:percent="percent"
type="warning"></t-progress-line>
</t-col>
</template>
<template v-if="area==4">
<t-section title="设置宽度"
class="mb-15"></t-section>
<t-col>
<t-progress-line class="w-50 mb-12"
:percent="percent"
type="success"></t-progress-line>
<t-progress-line class="w-100 mb-12"
:percent="percent"
type="error"></t-progress-line>
<t-progress-line class="w-150 mb-12"
:percent="percent"
type="primary"></t-progress-line>
<t-progress-line class="w-200"
:percent="percent"
type="warning"></t-progress-line>
</t-col>
</template>
<template v-if="area==5">
<t-section title="自定义颜色"
class="mb-15"></t-section>
<t-col>
<t-progress-line activeColor="#19be6b"
:percent="percent"
type="success"></t-progress-line>
</t-col>
</template>
<t-row class='fww r-10 p-10'>
<t-button type="success"
class="mrb-15"
size="small"
@click="area=1">基础功能+主题</t-button>
<t-button type="error"
class="mrb-15"
size="small"
@click="area=2">显示百分比</t-button>
<t-button type="primary"
class="mrb-15"
size="small"
@click="area=3">显示百分比</t-button>
<t-button type="warning"
class="mrb-15"
size="small"
@click="area=4">设置宽度</t-button>
<t-button type="primary"
class="mrbs-15"
size="small"
@click="area=5">自定义颜色</t-button>
</t-row>
</view>
</template>
<script setup
lang="ts">
// 引入 ref
import { ref } from 'vue';
// 定义响应式数据
const percent = ref<number>(50);
const area = ref<number>(1);
// 定义方法
const increase = () => {
percent.value = percent.value + 10;
if (percent.value > 100) percent.value = 100;
};
const reduce = () => {
percent.value = percent.value - 10;
if (percent.value < 0) percent.value = 0;
};
</script>t-progress-line Props
| 属性名 | 类型 | 默认值 | 说明 | 可选值 |
|---|---|---|---|---|
| size | String | "medium" | 组件尺寸 | large, medium, small, mini |
| type | String | "" | 组件类型 | info, primary, error, warning, success |
| disabled | Boolean | false | 组件是否禁用 | true, false |
| hover | Boolean | false | 是否有点击效果 | true, false |
| path | String | "" | 点击组件后跳转的页面路径 | - |
| effect | String | "normal" | 组件显示主题 | normal, dark, light, plain |
| percent | Number | 0 | 进度条的当前百分比 | 0-100 |
| showPercentage | Boolean | false | 是否显示进度百分比 | true, false |
| activeColor | String | "" | 进度条激活时的颜色 | - |
t-progress-line Events
| 事件名 | 说明 | 回调参数 |
|---|---|---|
| click | 点击时触发 | - |
| transitionend | 动画结束时触发 | - |
| initFinished | 组件初始化完成触发 | 组件的节点信息 |
| touchstart | 触摸开始时触发 | 触摸事件对象 |
| touchend | 触摸结束时触发 | 触摸事件对象 |
| touchmove | 触摸移动时触发 | 触摸事件对象 |
| touchcancel | 触摸取消时触发 | 触摸事件对象 |