You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have routes like users/new and users/list and users/edit and I want to write the logic that if the route starts with users then I want to return true for isRouteActive.
But the problem is that I cannot write route.path.startsWith('/users') because it won't work for localized routes like /es/users/
Here is my code:
<template>
<div :class="usersActiveClass">
Users
</div>
</template>
<scriptsetuplang="ts">const route =useRoute()const usersActiveClass =computed(() => {// (!) This won't work for '/es/users/list'returnroute.path.startsWith('/users') ?'bg-gray-200':'' })</script>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have routes like
users/new
andusers/list
andusers/edit
and I want to write the logic that if the route starts withusers
then I want to returntrue
for isRouteActive.But the problem is that I cannot write
route.path.startsWith('/users')
because it won't work for localized routes like/es/users/
Here is my code:
Beta Was this translation helpful? Give feedback.
All reactions