Skip to main content

loading.js

加载文件可以创建基于 悬念 的即时加载状态。

¥A loading file can create instant loading states built on Suspense.

默认情况下,该文件是 服务器组件 - 但也可以通过 "use client" 指令用作客户端组件。

¥By default, this file is a Server Component - but can also be used as a Client Component through the "use client" directive.

export default function Loading() {
// Or a custom loading skeleton component
return <p>Loading...</p>
}
export default function Loading() {
// Or a custom loading skeleton component
return <p>Loading...</p>
}

加载 UI 组件不接受任何参数。

¥Loading UI components do not accept any parameters.

很高兴知道:

¥Good to know:

  • 在设计加载 UI 时,你可能会发现使用 React 开发者工具 手动切换 Suspense 边界很有帮助。

    ¥While designing loading UI, you may find it helpful to use the React Developer Tools to manually toggle Suspense boundaries.

版本历史

¥Version History

版本变化
v13.0.0loading 推出。