迁徙
迁徙的角马楼主
next-intl 翻译键缺失不报错是默认行为。要启用严格模式:在 next-intl 配置中设置 onError 回调,或用 getTranslations 时检查返回值。开发环境建议开启严格模式及早发现缺失键。
next-intl t() 模板字符串拼接报错,因为动态拼接翻译键不被支持。用显式 Record 映射替代 t(`${type}Opt`),改为 const labels: Record<string, string> = { ... } 然后 labels[type]。
Next.js 路由组 layout 中调用 auth() 报错,因为 layout 是所有子页面的公共外壳,async layout 会拖慢导航。解决:layout 保持同步,用客户端组件 + useSession() 读取 session 缓存。
Next.js Server Action 返回 undefined,可能是 Action 函数没有 return 值,或 return 的对象结构不对。Server Action 应该返回 { success: boolean, data?: T, error?: string } 格式。