当我重新加载页面时,我的vue-router不会加载该组件,但在过渡时会加载

时间:2019-07-21 10:55:13

标签: javascript vue.js vue-router

App.vue:

<template>
  <div id="app">
    <header-section />
    <router-view class="child-container" />
    <bottom-nav v-if="!isAuthRoute" />
  </div>
</template>

我的router.js:


export default new Router({
    mode: 'history',
    base: process.env.BASE_URL,
    routes: [{
        path: '/',
        name: 'Authenticate',
        component: Authenticate,
    }, {
        path: 'conversations',
        name: 'ConversationsList',
        component: ConversationsList
    }, {
        path: 'conversations/:ConversationId',
        component: ConversationDetail,
        children: [{
            path: '',
            name: 'ConversationDetailHighlights',
            component: ConversationDetailHighlights

        }, {
            path: 'transcript',
            name: 'ConversationDetailFullTranscript',
            component: ConversationDetailFullTranscript

        }]
    }],

    scrollBehavior() {
        return { x: 0, y: 0 }
    }
});

当我单击链接转到/conversations时,它加载正常。但是,当我直接在浏览器中加载/conversations时,它不会加载ConversationsList组件:

enter image description here

1 个答案:

答案 0 :(得分:1)

您尝试使用path: '/conversations'吗?我敢肯定,只有在路由是path: '/'路由的子级时,才省略斜杠前缀