[英]vue-router won't render template on nested route
So I have a route like this: 所以我有这样的路线:
const routes = [{
path: '/',
component: Home,
children: [
{
path: "/health"
children: [
{
path: 'overview'
component: Overview
},
{
path: 'blood',
component: Blood
}
]
}
]
}]
and in the Home component I have something like this: 在Home组件中我有这样的东西:
<template>
<div id="home">
<router-view></router-view>
</div>
</template>
But when I navigate to the /health/overview
and /health/blood
routes, the templates corresponding to the components won't render. 但是当我导航到
/health/overview
和/health/blood
路线时,对应于组件的模板将不会呈现。 I checked the apps $route
objects, they correctly detect the routes and the components. 我检查了应用程序
$route
对象,他们正确检测路由和组件。 Just the template won't render. 只是模板不会呈现。 I also have a
<router-view>
in my App.vue
if that helps. 如果有帮助,我的
App.vue
也有<router-view>
。
Is it not possible to have multi nested routes? 是否有可能有多个嵌套路线? Or am I missing something?
或者我错过了什么?
The health route should be like this: 健康路径应该是这样的:
{
path: 'health', // not '/health'
component: Health, // this can just be a dummy component with a <router-view/>
children: [...],
},
If you don't need the Health
component at all for any reason (ie you don't have any shared functionality or template across each child), you can just remove the health route completely and replace it with this instead: 如果由于任何原因完全不需要
Health
组件(即每个子组件上没有任何共享功能或模板),则可以完全删除运行状况路径并将其替换为:
{
path: 'health/overview',
component: Overview,
},
{
path: 'health/blood',
component: Blood,
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.