核心内容摘要
百度浏览网站安全吗
蜘蛛池养多久才能用鱼
graph TD A[“undefined variable in line 1”] --> B{错误类型判定} B -->|未声明引用| C[ReferenceError: xxx is not defined] B -->|已声明但未初始化| D[TypeError: Cannot read property 'x' of undefined] C --> E[检查 script 标签顺序/ESM import 时机] D --> F[添加可选链操作符 user?.name 或空值合并 user ?? {}]