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
组件:
答案 0 :(得分:1)
您尝试使用path: '/conversations'
吗?我敢肯定,只有在路由是path: '/'
路由的子级时,才省略斜杠前缀