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當從頁面匯出 getServerSideProps 或 getInitialProps 時,它將被標記為動態。
版本歷史
| 版本 | 更改 |
|---|---|
v16.0.0 | appIsrStatus、buildActivity 和 buildActivityPosition 選項已移除。 |
v15.2.0 | 改進了螢幕指示器,新增了 position 選項。appIsrStatus、buildActivity 和 buildActivityPosition 選項已棄用。 |
v15.0.0 | 添加了帶有 appIsrStatus 選項的靜態螢幕指示器。 |
這有幫助嗎?