手写了一个给你:
export function getCookie(name: string): string { const value = `; ${document.cookie}`; const parts: string[] = value.split(`; ${name}=`); if (parts.length === 2) { return parts.pop()!.split(';').shift() || ''; } return ''; }