Cookie 名称
Cookie 值,如果不存在则返回 null
获取指定名称的 cookie 值
// 获取用户IDconst userId = getCookie('user_id');if (userId) { console.log('用户ID:', userId);} else { console.log('用户未登录');}// 获取主题设置const theme = getCookie('theme') || 'light'; Copy
// 获取用户IDconst userId = getCookie('user_id');if (userId) { console.log('用户ID:', userId);} else { console.log('用户未登录');}// 获取主题设置const theme = getCookie('theme') || 'light';
Cookie 名称