שאלו את שאלתכם וקבלו סיכום של המסמך על ידי הפניה לדף הזה ולספק ה-AI שתבחרו
היסטוריית גרסאות
- "Add usePathname utility"v10.0.023.6.2026
- "Init history"v8.2.022.6.2026
התוכן של הדף הזה תורגם באמצעות AI.
צפייה בגרסה האחרונה של התוכן המקורי באנגליתאם יש לכם רעיון לשיפור התיעוד הזה, אל תהססו לתרום על ידי הגשת Pull Request ב-GitHub.
קישור GitHub לתיעודהעתקת ה-Markdown של המסמך ללוח
Vue Integration: usePathname Composable Documentation
The usePathname composable returns the current browser pathname with the locale segment stripped, as a reactive ComputedRef<string>. It is useful for building locale-aware navigation (for example, determining which nav item is active) without having to manually remove the locale prefix.
Importing usePathname in Vue
העתקת הקוד ללוח
Overview
usePathname reads window.location.pathname, strips the locale prefix via getPathWithoutLocale, and updates automatically when the browser fires a popstate event (back/forward navigation). The result is exposed as a ComputedRef<string> so it integrates naturally with Vue's reactivity system.
Usage
העתקת הקוד ללוח
Return Value
פתיחת הטבלה בחלון כדי לראות את כל תוכן הנתונים בבירור
| Type | Description |
|---|---|
ComputedRef<string> | Reactive computed ref containing the current pathname without the locale prefix. |
Behavior
- Locale stripping: Removes the leading locale segment (e.g.
/fr/dashboard→/dashboard). - Reactive: Updates automatically on
popstateevents (browser back / forward navigation). - SSR-safe: Returns
""whenwindowis not available. - Cleanup: The
popstatelistener is removed automatically when the component is unmounted (onUnmounted).
Example
העתקת הקוד ללוח
