---
title: "<NuxtLoadingIndicator>"
description: "在页面导航之间显示进度条。"
canonical_url: "https://nuxt.zhcndoc.com/docs/4.x/api/components/nuxt-loading-indicator"
---
# <NuxtLoadingIndicator>

> 在页面导航之间显示进度条。

## 用法

在 [`app.vue`](https://nuxt.zhcndoc.com/docs/4.x/directory-structure/app/app) 或 [`app/layouts/`](https://nuxt.zhcndoc.com/docs/4.x/directory-structure/app/layouts) 中添加 `<NuxtLoadingIndicator/>`。

```vue [app/app.vue]
<template>
  <NuxtLoadingIndicator />
  <NuxtLayout>
    <NuxtPage />
  </NuxtLayout>
</template>
```

<link-example to="https://nuxt.zhcndoc.com/docs/4.x/examples/routing/pages">



</link-example>

## 插槽

你可以通过 loading indicator 的默认插槽传入自定义的 HTML 或组件。

## 属性

- `color`: 加载条的颜色。可以设置为 `false` 来关闭显式颜色样式。
- `errorColor`: 当 `error` 被设置为 `true` 时加载条的颜色。
- `height`: 加载条的高度，以像素为单位（默认 `3`）。
- `duration`: 加载条的持续时间，以毫秒为单位（默认 `2000`）。
- `throttle`: 出现和隐藏的节流时间，以毫秒为单位（默认 `200`）。
- `estimatedProgress`: 默认情况下，Nuxt 在接近 100% 时会逐渐放缓。你可以提供一个自定义函数来定制进度估算，该函数会接收加载条的持续时间（见上文）和已用时间。它应返回一个介于 0 到 100 之间的值。

<note>

此组件是可选的。 <br />


若要实现完全自定义，你可以基于 [其源码](https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/components/nuxt-loading-indicator.ts) 自行实现一个。

</note>

<note>

你可以使用 [`useLoadingIndicator` 组合式函数](https://nuxt.zhcndoc.com/docs/4.x/api/composables/use-loading-indicator)接入底层的指示器实例，从而自行触发 start/finish 事件。

</note>

<tip>

加载指示器在达到由 `estimatedProgress` 控制的特定点后，其速度会逐渐减慢。此调整能更准确地反映较长的页面加载时间，并防止指示器过早显示 100% 完成。

</tip>

---

- [源码](https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/components/nuxt-loading-indicator.ts)


## Sitemap

See the full [sitemap](https://nuxt.zhcndoc.com/sitemap.md) for all pages.
