主题
browserDebugInfoInTerminal
experimental.browserDebugInfoInTerminal
选项将来自浏览器的控制台输出和运行时错误转发到开发服务器终端。
¥The experimental.browserDebugInfoInTerminal
option forwards console output and runtime errors originating in the browser to the dev server terminal.
此选项默认禁用。启用后,它仅在开发模式下有效。
¥This option is disabled by default. When enabled it only works in development mode.
用法
¥Usage
启用转发:
¥Enable forwarding:
ts
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
experimental: {
browserDebugInfoInTerminal: true,
},
}
export default nextConfig
序列化限制
¥Serialization limits
使用合理的默认值截断深层嵌套的对象/数组。你可以调整以下限制:
¥Deeply nested objects/arrays are truncated using sensible defaults. You can tweak these limits:
深度限制:(可选)限制嵌套对象/数组的字符串化深度。默认:5
¥depthLimit: (optional) Limit stringification depth for nested objects/arrays. Default: 5
边缘限制:(可选)每个对象或数组包含的属性或元素的最大数量。默认:100
¥edgeLimit: (optional) Max number of properties or elements to include per object or array. Default: 100
ts
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
experimental: {
browserDebugInfoInTerminal: {
depthLimit: 5,
edgeLimit: 100,
},
},
}
export default nextConfig
源位置
¥Source location
启用此功能后,默认包含源位置。
¥Source locations are included by default when this feature is enabled.
tsx
'use client'
export default function Home() {
return (
<button
type="button"
onClick={() => {
console.log('Hello World')
}}
>
Click me
</button>
)
}
点击按钮会将此消息打印到终端。
¥Clicking the button prints this message to the terminal.
bash
[browser] Hello World (app/page.tsx:8:17)
要禁用它们,请设置 showSourceLocation: false
。
¥To suppress them, set showSourceLocation: false
.
显示源位置:包含源位置信息(如有)。
¥showSourceLocation: Include source location info when available.
ts
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
experimental: {
browserDebugInfoInTerminal: {
showSourceLocation: false,
},
},
}
export default nextConfig
版本 | 更改 |
---|---|
v15.4.0 | 引入实验性 browserDebugInfoInTerminal |