# @aacassandra/vue3-progressbar 中文文档

规范地址：https://npmcn.com/package/%40aacassandra/vue3-progressbar/

版本：1\.0\.3
npm 元数据更新时间：2022-04-04T10:54:56.682Z
中文译文更新时间：2026-11-05T23:49:12.792Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40aacassandra/vue3-progressbar
原文对照：https://npmcn.com/package/%40aacassandra/vue3-progressbar/?lang=original
项目主页：https://github.com/aacassandra/vue3-progressbar#readme
源码仓库：https://github.com/aacassandra/vue3-progressbar

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：145 kB，10 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：2 个
- 首次发布：2020-12-07T14:07:24.070Z
- 最新版本发布：2020-12-07T16:09:33.439Z
- 近 30 天下载量：9022（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：4（近 12 个月 0 个）

## 中文简介

Vuejs 3 的轻量级进度栏

## 安装

```sh
npm install @aacassandra/vue3-progressbar
```

也可以使用：`pnpm add @aacassandra/vue3-progressbar`、`yarn add @aacassandra/vue3-progressbar`、`bun add @aacassandra/vue3-progressbar`

## README

![](https://user-images.githubusercontent.com/29236058/101346079-a21fd600-38ba-11eb-9501-ff17ab71364b.png)

# Vue 3 进度栏

此前,我们首先要感谢那些愿意帮助全球开发商的开发商,特别是那些为开发公司做出贡献的开发商 [hilongjw/vue-进步栏](https://github.com/hilongjw/vue-progressbar)在这里,我继续从先前的开发中为vuejs版本3提供支持.

# 目录

-   [**_演示_**](https://npmcn.com/package/%40aacassandra/vue3-progressbar/#readme-demo)
-   [**_所需资源_**](https://npmcn.com/package/%40aacassandra/vue3-progressbar/#readme-requirements)
-   [**_安装_**](https://npmcn.com/package/%40aacassandra/vue3-progressbar/#readme-installation)
-   [**_使用量_**](https://npmcn.com/package/%40aacassandra/vue3-progressbar/#readme-usage)
-   [**_构造选项_**](https://npmcn.com/package/%40aacassandra/vue3-progressbar/#readme-constructor-options)
-   [**_执行情况_**](https://npmcn.com/package/%40aacassandra/vue3-progressbar/#readme-implementation)
-   [**_自行车_**](https://npmcn.com/package/%40aacassandra/vue3-progressbar/#readme-vue-router)
    -   [**_元选项_**](https://npmcn.com/package/%40aacassandra/vue3-progressbar/#readme-vue--router-meta-options)
-   [**_方法_**](https://npmcn.com/package/%40aacassandra/vue3-progressbar/#readme-methods)
-   [**_实例_**](https://npmcn.com/package/%40aacassandra/vue3-progressbar/#readme-examples)
-   [**_许可证_**](https://npmcn.com/package/%40aacassandra/vue3-progressbar/#readme-license)

# 演示

[**_演示_**](http://hilongjw.github.io/vue-progressbar/index.html)

# 所需资源

-   [Vue.js (英语)](https://github.com/vuejs/vue-next) `3.x`

# 安装

```bash
# npm
$ npm install @aacassandra/vue3-progressbar

```

# 使用量

主语.js

```javascript
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import VueProgressBar from "@aacassandra/vue3-progressbar";

const options = {
  color: "#bffaf3",
  failedColor: "#874b4b",
  thickness: "5px",
  transition: {
    speed: "0.2s",
    opacity: "0.6s",
    termination: 300,
  },
  autoRevert: true,
  location: "left",
  inverse: false,
};

createApp(App)
  .use(VueProgressBar, options)
  .use(router)
  .mount("#app");
```

## 构造选项

| 键 | 说明 | 默认 | 选项 |
| :-- | --- | --- | --- |
| `color` | 进度栏的颜色 | `'rgb(143, 255, 199)'` | `RGB` `HEX` `HSL` `HSV` `VEC` |
| `failedColor` | 负载失败时进度栏的颜色 | `'red'` | `RGB`, (中文(简体) ), `HEX`, (中文(简体) ), `HSL`, (中文(简体) ), `HSV`, (中文(简体) ), `VEC` |
| `thickness` | 进度栏的厚度 | `'2px'` | `px`, (中文(简体) ), `em`, (中文(简体) ), `pt`, (中文(简体) ), `%`, (中文(简体) ), `vh`, (中文(简体) ), `vw` |
| `transition` | 过渡速度/不透明/进度栏终止 | `{speed: '0.2s', opacity: '0.6s', termination: 300}` | `speed`, (中文(简体) ), `opacity`, (中文(简体) ), `termination` |
| `autoRevert` | 完成或失败时会自动返回临时颜色变化 | `true` | `true`, (中文(简体) ), `false` |
| `location` | 更改进度栏的位置 | `top` | `left`, (中文(简体) ), `right`, (中文(简体) ), `top`, (中文(简体) ), `bottom` |
| `position` | 更改进度栏的位置 | `fixed` | `relative`, (中文(简体) ), `absolute`, (中文(简体) ), `fixed` |
| `inverse` | 倒转进度栏的方向 | `false` | `true`, (中文(简体) ), `false` |
| `autoFinish` | 允许进程栏在接近100%时自动完成 | `true` | `true`, (中文(简体) ), `false` |

## 执行情况

应用vue

```html
<template>
  <div id="app">
    <!-- for example router view -->
    <router-view></router-view>
    <!-- set progressbar -->
    <vue-progress-bar></vue-progress-bar>
  </div>
</template>

<script>
  export default {
    mounted() {
      //  [App.vue specific] When App.vue is finish loading finish the progress bar
      this.$Progress.finish();
    },
    created() {
      //  [App.vue specific] When App.vue is first loaded start the progress bar
      this.$Progress.start();
      //  hook the progress bar to start before we move router-view
      this.$router.beforeEach((to, from, next) => {
        //  does the page we want to go to have a meta.progress object
        if (to.meta.progress !== undefined) {
          let meta = to.meta.progress;
          // parse meta tags
          this.$Progress.parseMeta(meta);
        }
        //  start the progress bar
        this.$Progress.start();
        //  continue to next page
        next();
      });
      //  hook the progress bar to finish after we've finished moving router-view
      this.$router.afterEach((to, from) => {
        //  finish the progress bar
        this.$Progress.finish();
      });
    },
  };
</script>
```

## 自行车

```js
export default [
  {
    path: "/achievement",
    name: "achievement",
    component: "./components/Achievement.vue",
    meta: {
      progress: {
        func: [
          { call: "color", modifier: "temp", argument: "#ffb000" },
          { call: "fail", modifier: "temp", argument: "#6e0000" },
          { call: "location", modifier: "temp", argument: "top" },
          {
            call: "transition",
            modifier: "temp",
            argument: { speed: "1.5s", opacity: "0.6s", termination: 400 },
          },
        ],
      },
    },
  },
];
```

### vue-router 元选项

| 调用 | 修改 | 参数 | 实例 |
| :-- | --- | --- | --- |
| 颜色 | `set`, (中文(简体) ), `temp` | `string` | `{call: 'color', modifier: 'temp', argument: '#ffb000'}` |
| 失败 | `set`, (中文(简体) ), `temp` | `string` | `{call: 'fail', modifier: 'temp', argument: '#ffb000'}` |
| 地点 | `set`, (中文(简体) ), `temp` | `string` | `{call: 'location', modifier: 'temp', argument: 'top'}` |
| 过渡 | `set`, (中文(简体) ), `temp` | `object` | `{call: 'transition', modifier: 'temp', argument: {speed: '0.6s', opacity: '0.6s', termination: 400}}` |

# 方法

| 函数 | 说明 | 参数 | 实例 |
| :-- | --- | --- | --- |
| 开始 | 启动进度栏加载 | `N/A` | `this.$Progress.start()` |
| 结束 | 完成进度栏加载 | `N/A` | `this.$Progress.finish()` |
| 失败 | 导致进度栏结束并失败 | `N/A` | `this.$Progress.fail()` |
| 增加 | 将进度栏增加一定百分比 | `number: integer` | `this.$Progress.increase(number)` |
| 减少 | 将进度栏减少一定百分比 | `number: integer` | `this.$Progress.decrease(number)` |
| 设定 | 设置进度栏% | `number: integer` | `this.$Progress.set(number)` |
| 设置失败颜色 | 导致失败颜色永久更改 | `color: string` | `this.$Progress.setFailColor(color)` |
| 设置颜色 | 使进度颜色永久更改 | `color: string` | `this.$Progress.setColor(color)` |
| 设置 | 使进度栏位置永久更改 | `location: string` | `this.$Progress.setLocation(location)` |
| 转换 | 使进度栏的过渡速度/不透明/终止永久更改 | `transition: object` | `this.$Progress.setTransition(transition)` |
| 临时故障颜色 | 导致失败颜色改变( 暂时) | `color: string` | `this.$Progress.tempFailColor(color)` |
| 临时颜色 | 使进度颜色发生变化(暂时) | `color: string` | `this.$Progress.tempColor(color)` |
| 温度 | 导致进度栏位置发生变化(暂时) | `location: string` | `this.$Progress.tempLocation(location)` |
| 临时过渡 | 导致进度栏位置发生变化(暂时) | `transition: object` | `this.$Progress.tempTransition(transition)` |
| 还原颜色 | 使临时设置的进度颜色返回到以前的颜色 | `N/A` | `this.$Progress.revertColor()` |
| 返回失败颜色 | 因为临时设定的失败颜色返回到以前的颜色 | `N/A` | `this.$Progress.revertFailColor()` |
| 回转 | 让临时设定的过渡恢复到以前的状态 | `N/A` | `this.$Progress.revertTransition()` |
| 还原 | 使临时设置的进度和/或失败颜色变为以前的颜色 | `N/A` | `this.$Progress.revert()` |
| 解析器 | 剖析进度元数据 | `meta: object` | `this.$Progress.parseMeta(meta)` |

# 实例

正在装入数据( Vue- 资源)

```html
<script>
  export default {
    methods: {
      test() {
        this.$Progress.start();
        this.$http
          .jsonp(
            "http://api.rottentomatoes.com/api/public/v1.0/lists/movies/in_theaters.json?apikey=7waqfqbprs7pajbz28mqf6vz"
          )
          .then(
            (response) => {
              this.$Progress.finish();
            },
            (response) => {
              this.$Progress.fail();
            }
          );
      },
    },
  };
</script>
```

* * *

通过 vue 实例(例如轴截取器)外部访问进度栏

**主语.js**

```js
// main.js from Usage section

Vue.use(VueProgressBar, options);

export default new Vue({
  // export the Vue instance
  ...App,
}).$mount("#app");
```

**api-axios.js (英语)**

```js
import axios from "axios";
import app from "../main"; // import the instance

const instance = axios.create({
  baseURL: "/api",
});

instance.interceptors.request.use((config) => {
  app.$Progress.start(); // for every request start the progress
  return config;
});

instance.interceptors.response.use((response) => {
  app.$Progress.finish(); // finish when a response is received
  return response;
});

export default instance; // export axios instance to be imported in your app
```

# 自由主义

```
MIT License

Copyright (c) 2020 Alauddin Afif Cassandra

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
```

见 [更多](https://github.com/aacassandra/vue3-progressbar/blob/master/LICENSE) 关于自由

## 常见问题

### @aacassandra/vue3-progressbar 是什么？

Vuejs 3 的轻量级进度栏

### 如何安装 @aacassandra/vue3-progressbar？

在项目目录运行 npm install @aacassandra/vue3-progressbar，或使用 pnpm add / yarn add / bun add。

### @aacassandra/vue3-progressbar 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/aacassandra\_\_vue3-progressbar 是否存在。

### @aacassandra/vue3-progressbar 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @aacassandra/vue3-progressbar 可以商用吗？

@aacassandra/vue3-progressbar 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @aacassandra/vue3-progressbar 的下载量有多少？

根据 npm 官方下载统计，@aacassandra/vue3-progressbar 在 2026/10/05 – 2026/11/03 这 30 天内被下载 9,022 次，日均约 301 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @aacassandra/vue3-progressbar 还在维护吗？

最新版本 1\.0\.3 发布于 2020/12/08（5 年前）；至今共发布 4 个版本，其中过去 12 个月发布了 0 个；首次发布于 2020/12/07。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

