Skip to content

Commit e7c71dc

Browse files
committed
feat: progress format support v-slot #1348
1 parent c33965d commit e7c71dc

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

components/progress/demo/format.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ You can set a custom text by setting the `format` prop.
1313
<div>
1414
<a-progress type="circle" :percent="75" :format="percent => `${percent} Days`" />
1515
<a-progress type="circle" :percent="100" :format="() => 'Done'" />
16+
<a-progress type="circle" :percent="75">
17+
<template v-slot:format="percent">
18+
<span style="color: red">{{percent}}</span>
19+
</template>
20+
</a-progress>
1621
</div>
1722
</template>
1823
<style scoped>

components/progress/index.en-US.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Properties that shared by all types.
55
| Property | Description | Type | Default |
66
| --- | --- | --- | --- |
77
| type | to set the type, options: `line` `circle` `dashboard` | string | `line` |
8-
| format | template function of the content | function(percent, successPercent) | `percent => percent + '%'` |
8+
| format | template function of the content | function(percent, successPercent) \| v-slot:format="percent, successPercent" | `percent => percent + '%'` |
99
| percent | to set the completion percentage | number | 0 |
1010
| showInfo | whether to display the progress value and the status icon | boolean | true |
1111
| status | to set the status of the Progress, options: `success` `exception` `active` `normal` | string | - |

components/progress/index.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| 属性 | 说明 | 类型 | 默认值 |
66
| --- | --- | --- | --- |
77
| type | 类型,可选 `line` `circle` `dashboard` | string | `line` |
8-
| format | 内容的模板函数 | function(percent, successPercent) | `percent => percent + '%'` |
8+
| format | 内容的模板函数 | function(percent, successPercent) \| v-slot:format="percent, successPercent" | `percent => percent + '%'` |
99
| percent | 百分比 | number | 0 |
1010
| showInfo | 是否显示进度数值或状态图标 | boolean | true |
1111
| status | 状态,可选:`success` `exception` `active` `normal` | string | - |

components/progress/progress.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,14 @@ export default {
5353
if (!showInfo) return null;
5454

5555
let text;
56-
const textFormatter = format || (percentNumber => `${percentNumber}%`);
56+
const textFormatter =
57+
format || this.$scopedSlots.format || (percentNumber => `${percentNumber}%`);
5758
const iconType = type === 'circle' || type === 'dashboard' ? '' : '-circle';
58-
if (format || (progressStatus !== 'exception' && progressStatus !== 'success')) {
59+
if (
60+
format ||
61+
this.$scopedSlots.format ||
62+
(progressStatus !== 'exception' && progressStatus !== 'success')
63+
) {
5964
text = textFormatter(validProgress(percent), validProgress(successPercent));
6065
} else if (progressStatus === 'exception') {
6166
text = <Icon type={`close${iconType}`} theme={type === 'line' ? 'filled' : 'outlined'} />;

0 commit comments

Comments
 (0)