0
votes

I have a issue while using vue-router nested routes.

https://router.vuejs.org/guide/essentials/nested-routes.html

I have parent route User and child route UserQuotes, which is not rendering. No error or warning in console. Vue devtools is not showing UserQuotes at all.

url: http://localhost:8080/user/lagin/quotes

enter image description here

./src/router/index.js

import User from '@/components/User'
import UserQuotes from '@/components/UserQuotes'

export default new Router({
    mode: 'history',
    saveScrollPosition: true,
    base: __dirname,
    routes: [
        {
            path: '/user/:name',
            name: 'User',
            component: User,
            children: [
                {
                    path: 'quotes',
                    component: UserQuotes
                }
            ]
        }
    ]
})

./src/compoments/User.vue

<template>
    <div v-if="user" class="user">
        <h2>{{ user.name }}</h2>

        <ul class="list-group">
            <li v-for="(value, key) in user" class="list-group-item">{{ key }}: {{ value }}</li>
        </ul>

        <router-view></router-view>
    </div>
</template>

<script>
    export default {
        name: 'user',
        props: {

        },
        data() {
            return {

            }
        },
        computed: {
            user: function() {
                return this.$store.state.user
            }
        },
        methods: {

        }
    }
</script>

./src/compoments/UserQuotes.vue

<template>
    <div class="user-quotes">
        <h2>User quotes</h2>
    </div>
</template>

<script>
    export default {
        name: 'userQuotes',
        props: {

        },
        data() {
            return {

            }
        },
        computed: {

        },
        methods: {

        }
    }
</script>
1
did you ever figure this out i'm running into the same issue - Paul Brunache

1 Answers

0
votes

I don't really see the need for base: __dirname, but maybe I'm missing something.

Tried to add this parameter to one of my projects with nested routes, which broke the application in similar fashion you're describing. Try to remove it altogether and see if that fixes your problem.