Hi,
I'm using the Tailwind version of Metronic with Vue 3 and Nuxt 3. The sticky component works fine when the page initially loads, but after navigating to a different route, the sticky elements don't function correctly. I tried updating them, but it didn't work.
import KTComponent, { KTSticky } from "./assets/metronic/core/index"
import KTLayout from "./assets/metronic/app/layouts/demo1"
const route = useRoute()
watch(() => route.path, () => {
nextTick(() => {
KTComponent.init()
KTLayout.init()
setTimeout(() => {
const components = document.querySelectorAll("[data-sticky="true"]")
components.forEach((element) => {
const sticky = KTSticky.getOrCreateInstance(element)
sticky.update()
})
}, 100)
})
})
It sounds like the sticky component needs to be re-initialized after route changes. Try using Vue's nextTick() or a watcher to manually trigger the update when navigating between routes.
seriesdonghua.org
Hi,
Thank you for reaching out to us.
Unfortunately, at the moment, we haven't tried combining Metronic with Nuxt 3, we will check it and consider implementing Nuxt in the next releases.
To fix this problem please make sure to call Metronic initialization functions after your content is mounted and call initialization on every page separately.
You can checkout our Next.js integration guide, and implement the initialization the same way for your Nuxt project.
https://keenthemes.com/metronic/tailwind/docs/getting-started/integration/nextjs
Regards,
Lauris Stepanovs,
Keenthemes Support Team