Answer the question
In order to leave comments, you need to log in
How to pass this.$route to header?
Hello!
I have this index.blade.php
<div id="app">
<header-component></header-component>
<navbar-component></navbar-component>
<router-view></router-view>
<footer-component></footer-component>
</div>
const routes=[
{
path:"/",
name: 'Home',
component: () => import('./views/index.vue')
},
{
path:"/about",
name: 'About',
component: () => import('./views/about.vue')
},
....
Vue.component('header-component', require('./components/Header.vue').default);
Vue.component('navbar-component', require('./components/Categorybar.vue').default);
Vue.component('footer-component', require('./components/Footer.vue').default);
Answer the question
In order to leave comments, you need to log in
It turned out that the console was displaying the wrong value.
If you write console.log(this.$route); , then it outputs the value of the initial page.
If you use this.$route inside the component, then it will return the parameters of the current route, even if console.log displays the values of the initial page.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question