Skip to content

devIndicators

devIndicators 允许你配置屏幕指示器,该指示器提供有关你在开发过程中正在查看的当前路由的上下文。

¥devIndicators allows you to configure the on-screen indicator that gives context about the current route you're viewing during development.

ts
  devIndicators: false | {
    position?: 'bottom-right'
    | 'bottom-left'
    | 'top-right'
    | 'top-left', // defaults to 'bottom-left',
  },

devIndicators 设置为 false 将隐藏指示器,但 Next.js 将继续显示遇到的任何构建或运行时错误。

¥Setting devIndicators to false will hide the indicator, however Next.js will continue to surface any build or runtime errors that were encountered.

故障排除

¥Troubleshooting

指示器未将路由标记为静态

¥Indicator not marking a route as static

如果你希望路由是静态的,而指示器已将其标记为动态,则路由很可能已选择退出静态渲染。

¥If you expect a route to be static and the indicator has marked it as dynamic, it's likely the route has opted out of static rendering.

你可以通过使用 next build --debug 构建应用并检查终端中的输出来确认路由是 static 还是 dynamic。静态(或预渲染)路由将显示 符号,而动态路由将显示 ƒ 符号。例如:

¥You can confirm if a route is static or dynamic by building your application using next build --debug, and checking the output in your terminal. Static (or prerendered) routes will display a symbol, whereas dynamic routes will display a ƒ symbol. For example:

bash
Route (app)                              Size     First Load JS
 /_not-found                          0 B               0 kB
 ƒ /products/[id]                       0 B               0 kB

  (Static)   prerendered as static content
ƒ  (Dynamic)  server-rendered on demand

有两个原因可能导致路由选择退出静态渲染:

¥There are two reasons a route might opt out of static rendering:

检查你的路由是否存在以下任何情况,如果你无法静态渲染路由,请考虑使用 loading.js<Suspense /> 来利用 streaming

¥Check your route for any of these conditions, and if you are not able to statically render the route, then consider using loading.js or <Suspense /> to leverage streaming.

版本历史

¥Version History

版本更改
v15.2.0使用新的 position 选项改进了屏幕指示器。appIsrStatusbuildActivitybuildActivityPosition 选项已被弃用。
v15.0.0使用 appIsrStatus 选项添加了静态屏幕指示器。

Next.js v15.2 中文网 - 粤ICP备13048890号