Answer the question
In order to leave comments, you need to log in
How to add a class to an element described in app but in a different router-view element in vue 3?
<template>
<header>
...
</header>
<router-view/>
<footer>
...
</footer>
</template>
Answer the question
In order to leave comments, you need to log in
Via computed property
<template>
<header :class="pageClass">
...
</header>
<router-view/>
<footer :class="pageClass">
...
</footer>
</template>
<script>
export default {
computed: {
pageClass() {
return {
'page-class': this.$route.path === '/page',
}
}
}
}
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question