我无法弄清楚当我在子路线上导航时发生了什么(在上面的示例http://<mydomain>/applis
中),然后刷新页面=&gt;我有一个
未找到//在此服务器上找不到请求的URL / applis
import MyComponentView from './components/MyComponent.vue'
import LoginView from './components/Login.vue'
import NotFoundView from './components/404.vue'
import DashboardView from './components/subcomp1/Dashboard.vue'
import ApplisView from './components/subcomp1/Applis.vue'
const routes = [
{
path: '/login',
component: LoginView
}, {
path: '/',
component: MyComponentView,
children: [
{
path: '',
component: DashboardView,
name: 'Dashboard',
description: 'Overview of environment'
}, {
path: '/applis',
component: ApplisView,
name: 'Applis',
description: 'Applications list'
}
]
}, {
path: '/*',
component: NotFoundView
}
]
export default routes
可能我不理解儿童路线的基本概念?
答案 0 :(得分:0)
在您的案例中,如果您已经拥有/
路线,那么您的父路线会显示/login
。这也是/
的孩子。正如documentation所说:
以/开头的嵌套路径将被视为根路径。这允许您利用组件嵌套而无需使用嵌套URL。
您可以查看示例here,了解如何使用嵌套路由。此链接的示例代码:
const router = new VueRouter({
routes: [
{ path: '/user/:id', component: User,
children: [
// UserHome will be rendered inside User's <router-view>
// when /user/:id is matched
{ path: '', component: UserHome },
// UserProfile will be rendered inside User's <router-view>
// when /user/:id/profile is matched
{ path: 'profile', component: UserProfile },
// UserPosts will be rendered inside User's <router-view>
// when /user/:id/posts is matched
{ path: 'posts', component: UserPosts }
]
}
]
})
如果您可以创建一个改动的小提琴,这将有助于提供精确的修复。