大叔
大叔楼主
Vercel 部署后 CSS 丢失,常见原因:① Tailwind content 路径没包含组件目录 ② CSS 被 PurgeCSS 误删 ③ 生产构建时 PostCSS 配置问题 ④ 部分样式只在 Client Component 中生效但被服务端渲染时缺失。
next-intl t() 模板字符串拼接报错,因为动态拼接翻译键不被支持。用显式 Record 映射替代 t(`${type}Opt`),改为 const labels: Record<string, string> = { ... } 然后 labels[type]。
React Server Component 中使用 useState 报错,因为 Server Component 不能用 hooks。解决:① 把需要状态的组件拆成 Client Component(加 'use client') ② 父组件保持 Server Component 做数据获取,子组件 Client 做交互。