You could use a middleware to execute some function before each page is rendered: https://nuxtjs.org/guide/routing#middleware
Another way would be to watch the $route property in your layout:
// layout/default.vue
export default {
watch: {
$route () {
console.log('route changed', this.$route)
}
},
}
I search the same but not when the route change, rather after the page is rendered.
I did not find anything in doc or forum ...
I need this because i need to apply css class according to the current page in order to apply different style.
So i need to apply these class just when the dom is rendered.
Any idea ?
@usb248 you could add some logic to your pages mounted hook to do this.
If you still have this issue, I'd recommend you open another thread as this is unrelated to the original issue.
Closing this now as there was no more follow up by the original poster.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
You could use a middleware to execute some function before each page is rendered: https://nuxtjs.org/guide/routing#middleware
Another way would be to watch the
$routeproperty in your layout: