#activeClass Nuxt Link
29 messages · Page 1 of 1 (latest)
router-link-active
and
router-link-exact-active
/about/contact
/about = router-link-active
/about/contact = router-link-exact-active
but you have to use NuxtPage, and nested NuxtPages
Sorry i do not understand this. This seems to be not related.
the default activeClass for NuxtLinks
The official router for Vue.js.
i was giving you an example, if the current route is /about/contact any NuxtLink elements linking to /about/contact will have router-link-exact-active class
but, in order for any of this to work, you need to be using NuxtPage
why are you assuming that i do not use <NuxtPage>?
My question why the properties differ.
https://nuxt.com/docs/api/components/nuxt-link
tells me the propertie is called "activeClass" but this is not working. Why"active-class" is working?
why do you think i'm assuming that you aren't?
i'm just saying how it works, i have no idea how you've configured things
are you just trying to configure custom active link classes?
or are you having trouble getting the active classes to work in general
why the property name differs. The problem appears when i want to apply a css class to an active link.
<NuxtLink
activeClass="myClass"
... as i interpreted the docs - wont work
<NuxtLink
active-class="myClass"
... does work.
with any vue/nuxt props, any camel-case props are written with dashes in an element
so activeClass technically is active-class
but if, for instance, you were using defineNuxtLink, it would be activeClass
export default defineNuxtLink({
componentName: 'CustomNuxtLink',
activeClass: 'my-active-class',
exactActiveClass: 'my-exact-active-class',
});
that documentation could probably be worded better
yes that hits the point, i wonder if i do not get the concept or if its a failure. so it seems to be grown and the docs refer to defineLink while i thought it describes the element tag.
but that naming/usage methodology basically applies for everything in vue/nuxt when you're moving between <script> and templates/html
so i think the author has just assumed that was implied knowledge
even that's a bad description 😄
anyway - if you're interested:
https://stackblitz.com/edit/define-nuxt-link?file=components%2FCustomNuxtLink.ts
Too much magick in vue... maybe i miss the scope according to the basics.
So the one describes the object constructor ending in an vue element, where the other is the ready to use vue element.
Thanks for helping to clarify. Would you recommend to use the one over the other?