扫码关注官方订阅号
在使用vue-router的时候发现有children设置,但是设置并没有达到网上看到的效果,请问是哪里代码错误。
我访问 http://localhost:8080/#/ 出现 Hello组件
但是我访问http://localhost:8080/#/test/a 却没有出现 Test组件的内容
闭关修行中......
嵌套路由表达组件的嵌套关系,子路由a的父级并没有指定component,所以就不会有内容出现了。而且父级组件还必须包含<router-view>才行。例如:
component
<router-view>
{ path: '/test', name: 'test', component: Test, children: [ { path: '/a', name: 'a', component: A } ] },
component Test:
<template> <p> <h1>this is component test</h1> <router-view></router-view> </p> </template>
文档链接https://router.vuejs.org/zh-cn/essentials/nested-routes.html
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
嵌套路由表达组件的嵌套关系,子路由a的父级并没有指定
component,所以就不会有内容出现了。而且父级组件还必须包含<router-view>才行。例如:component Test:
文档链接https://router.vuejs.org/zh-cn/essentials/nested-routes.html