google identity services(gis)sdk 突然报错 `._$e`,通常源于 `renderbutton` 配置项 `width` 类型变更——从字符串强制改为数字类型,需将 `'200'` 改为 `200`,否则触发静默失败。
近期许多开发者反馈,在未修改代码的情况下,Google 登录按钮初始化突然失败,并在浏览器控制台出现类似 Uncaught TypeError: Cannot read properties of undefined (reading '_$e') 或直接指向
核心原因在于:Google 已悄然将 window.google.accounts.id.renderBu

✅ 正确写法(推荐):
const button = document.getElementById('g_id_onload');
window.google.accounts.id.renderButton(button, {
type: 'standard',
theme: 'outline',
size: 'large',
width: 200, // ← 必须为 number 类型,不可加引号
text: 'signin_with',
logo_alignment: 'left'
});❌ 错误写法(将立即触发 ._$e):
// 即使值正确,字符串类型也会导致失败
window.google.accounts.id.renderButton(button, {
width: '200' // ❌ 字符串 —— 不再被接受
});⚠️ 注意事项:
renderButton(button, { width: 200 as number });总结:这不是兼容性降级,而是 Google 向更健壮的类型安全演进的信号。将所有 width、潜在 height 等数值配置去引号化,即可快速恢复功能。建议将此检查纳入 CI 构建或代码审查清单,防范同类隐式类型变更带来的线上故障。