跳到內容

devIndicators

devIndicators 允許您配置在開發過程中提供當前正在檢視的路由上下文的螢幕指示器。

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

devIndicators 設定為 false 將隱藏指示器,但 Next.js 將繼續顯示遇到的任何構建或執行時錯誤。

故障排除

指示器未將路由標記為靜態

如果您期望某個路由是靜態的,但指示器將其標記為動態的,則該路由很可能已選擇退出靜態渲染。

您可以透過使用 next build --debug 構建應用程式來確認路由是靜態還是動態,並在終端中檢查輸出。靜態(或預渲染)路由將顯示 符號,而動態路由將顯示 ƒ 符號。例如:

構建輸出
Route (app)
  /_not-found
 ƒ /products/[id]
 
  (Static)   prerendered as static content
ƒ  (Dynamic)  server-rendered on demand

當從頁面匯出 getServerSidePropsgetInitialProps 時,它將被標記為動態。

版本歷史

版本更改
v16.0.0appIsrStatusbuildActivitybuildActivityPosition 選項已移除。
v15.2.0改進了螢幕指示器,新增了 position 選項。appIsrStatusbuildActivitybuildActivityPosition 選項已棄用。
v15.0.0添加了帶有 appIsrStatus 選項的靜態螢幕指示器。