vant/src/progress/README.md
2021-04-08 09:57:55 +08:00

94 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Progress
### Intro
Used to show the current progress of the operation.
### Install
Register component globally via `app.use`, refer to [Component Registration](#/en-US/advanced-usage#zu-jian-zhu-ce) for more registration ways。
```js
import { createApp } from 'vue';
import { Progress } from 'vant';
const app = createApp();
app.use(Progress);
```
## Usage
### Basic Usage
Use `percentage` prop to set current progress.
```html
<van-progress :percentage="50" />
```
### Stroke Width
```html
<van-progress :percentage="50" stroke-width="8" />
```
### Inactive
```html
<van-progress inactive :percentage="50" />
```
### Custom Style
Use `pivot-text` to custom textuse `color` to custom bar color.
```html
<van-progress pivot-text="Orange" color="#f2826a" :percentage="25" />
<van-progress pivot-text="Red" color="#ee0a24" :percentage="50" />
<van-progress
:percentage="75"
pivot-text="Purple"
pivot-color="#7232dd"
color="linear-gradient(to right, #be99ff, #7232dd)"
/>
```
## API
### Props
| Attribute | Description | Type | Default |
| --- | --- | --- | --- |
| percentage | Percentage | _number \| string_ | `0` |
| stroke-width | Stroke width | _number \| string_ | `4px` |
| color | Color | _string_ | `#1989fa` |
| track-color | Track color | _string_ | `#e5e5e5` |
| pivot-text | Pivot text | _string_ | percentage |
| pivot-color | Pivot text background color | _string_ | inherit progress color |
| text-color | Pivot text color | _string_ | `white` |
| inactive | Whether to be gray | _boolean_ | `false` |
| show-pivot | Whether to show text | _boolean_ | `true` |
### Methods
Use [ref](https://vuejs.org/v2/api/#ref) to get Progress instance and call instance methods.
| Name | Description | Attribute | Return value |
| --- | --- | --- | --- |
| resize | Resize Progress when container element resized or visibility changed | - | - |
### Less Variables
How to use: [Custom Theme](#/en-US/theme).
| Name | Default Value | Description |
| -------------------------------- | --------------- | ----------- |
| @progress-height | `4px` | - |
| @progress-color | `@blue` | - |
| @progress-background-color | `@gray-3` | - |
| @progress-pivot-padding | `0 5px` | - |
| @progress-pivot-text-color | `@white` | - |
| @progress-pivot-font-size | `@font-size-xs` | - |
| @progress-pivot-line-height | `1.6` | - |
| @progress-pivot-background-color | `@blue` | - |