-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove vue-router support from Menu components #4739
Comments
Hello @tugcekucukoglu |
@Payn You can do something like this: <template>
<TabMenu :model="menuItems" :active-index="activeMenuItemIndex">
<template #item="{ item, props }">
<router-link v-if="item.route" v-slot="{ href, navigate }" :to="item.route" custom>
<a :href="href" v-bind="props.action" @click="navigate">
<span :class="item.icon" />
<span class="ml-2">{{ item.label }}</span>
</a>
</router-link>
</template>
</TabMenu>
</template>
<script setup>
import { ref, watch } from 'vue';
import { useRoute } from 'vue-router';
const route = useRoute();
const activeMenuItemIndex = ref(0);
const menuItems = [
{ label: 'MyTabOne', icon: 'pi pi-fw pi-code', route: '/tabone' },
{ label: 'MyTabTwo', icon: 'pi pi-fw pi-book', route: '/tabtwo' },
{ label: 'MyTabThree', icon: 'pi pi-fw pi-id-card', route: '/tabthree' },
];
watch(
() => route.path,
(updatedPath) => {
activeMenuItemIndex.value = menuItems.findIndex((item) => updatedPath.startsWith(item.route));
},
{ immediate: true }
);
</script> The activeMenuItemIndex.value = menuItems.findIndex((item) => item.route === updatedPath ); for the exact active class. |
Awesome, this works. Thank you. |
Any reason on why this has been removed? |
You can find the explanation here. |
@tugcekucukoglu This is a breaking change and yet not mentioned in the 3.40 changelog? |
We just discovered about this change. I think it is a big issue to use semantic versioning and introduce a breaking change in minor version bump. |
The text was updated successfully, but these errors were encountered: