Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

david001's avatar

vue router(router-view) not rendering components

Hi I am using vue3 and vue router. I have made few components but when I click the link, the URL works but pages/components are not displayed. I am using vue in laravel9.

app.js

import './bootstrap';

import '../sass/app.scss'

import {createApp} from 'vue'
import { createRouter, createWebHistory } from 'vue-router';
import routes from './routes.js';
import App from './App.vue'
import Profile from './Profile.vue'

const router = createRouter({
    history: createWebHistory(),
    routes: routes.routes,
  });
createApp(App).use(router).mount("#home")

Profile.vue //component

<template>
	<div>Profile</div>
</template>

routes.js

import App from './App.vue';
import Profile from './Profile.vue';

export default {
    routes: [

        {
            path: '/home',
            name: 'App',
            component: App,
         
        },

        {
            path: '/profile',
            name: 'Profile',
            component: Profile,
         
        },
    ],
};

Home.blade.php

@section('content')
<div class="container">
    <div id="home">
        <router-view></router-view>
    </div>
</div>
@endsection

Link in App.vue

 <div class="d-flex pt-1">
        <router-link to ='/profile'>Profile component</router-link>
 </div>

My profile component is not showing when I click profile link

0 likes
7 replies
tykus's avatar

App.vue is the root component or a page?

david001's avatar

@tykus App.vue is a just a component like profile.vue, I just have to make it to Home.vue as the name is confusing.

david001's avatar

@tykus yes, App.vue is the main component. In home.blade.php , I have div id as home, so I have used same id in app.js to mount component I don't have app as div id In app.blade.php

tykus's avatar
tykus
Best Answer
Level 104

@david001 you’re missing my point.

Rename App.vue to Home.vue, and update your routes. Make a new App.vue and move <router-view>in there

theusernamehasalreadybeentaken2's avatar

@tykus Why did this work please? I think I had a similar problem but making my app.vue component into home for the / route didn't work for me and I'm not sure I understand how it helped in this case.

Please or to participate in this conversation.