Reputation: 399
I have declared a route to which I want to pass a prop to show one or another header in my index component, but I cannot access the prop in any way ...
{
path: '/tienda/:id',
name: 'tienda',
component: InicioSistema,
props: { headersistema: true, }
},
In my Header.vue
<div v-if="this.$route.props.headersistema">
A header...
</div>
<div v-else>
Show Other header..
</div>
Upvotes: 0
Views: 71
Reputation: 2230
<script>
export default {
props: ['headersistema'],
};
</script>
in order to test add the below inside script:
mounted() {
if (this.headersistema){
console.log(this.headersistema, 'headersistema')
}
},
Upvotes: 0
Reputation: 735
Remove this
from v-if
. Vue already binds this
when templating.
<template>
<div v-if="$route.props.headersistema">A header...</div>
<div v-else>Show Other header..</div>
</template>
Upvotes: 1