Vue-Router嵌套路由
2024-10-18 19:24:58
1:查看router-view所对应的位置,是属于顶级出口还是存在于某个组件当中
2:当router-view存在于某个组件当中时
const User = {
template: `
<div class="user">
<h2>User {{ $route.params.id }}</h2>
<router-view></router-view>
</div>
`
}
那么我们在路由文件中,定义对应user的路由当中,需要添加子路由形式
const router = new VueRouter({
routes: [
{ path: '/user/:id', component: User,
children: [
{
// 当 /user/:id/profile 匹配成功,
// UserProfile 会被渲染在 User 的 <router-view> 中
path: 'profile',
component: UserProfile
},
{
// 当 /user/:id/posts 匹配成功
// UserPosts 会被渲染在 User 的 <router-view> 中
path: 'posts',
component: UserPosts
},
// 当 /user/:id 匹配成功,
// UserHome 会被渲染在 User 的 <router-view> 中
{ path: '', component: UserHome },
]
}
]
})
** 以'/'开头的嵌套路径会被当作根路径,合理的模式是给每个级别的路由都添加空的子路由
最新文章
- SharePoint 2010 数据库xxx的事务日志已满
- diff生成补丁与patch打补丁
- ReStart
- 数论 - 简单数位推理 --- NYIST 514
- JavaScriptSerializer中日期序列化问题解决方案
- 【转】Profiling application LLC cache misses under Linux using Perf Events
- AOD.net
- MySQL数据库获取汉字拼音的首字母函数
- linux处置服务Iptables
- kubernetes1.4 基础篇:Learn Kubernetes 1.4 by 6 steps
- python实现的txt目录树
- .Net中的并行编程-7.基于BlockingCollection实现高性能异步队列
- zabbix误报交换机重启
- Android屏幕亮度调节相关源码
- MVC 5 调用存储过程参数配置方法-Procedure or function &#39;UP_***&#39; expects parameter &#39;@****&#39;, which was not supplied.
- Spring Boot + Spring Cloud 实现权限管理系统 后端篇(二十一):服务网关(Zuul)
- poi excel 设置边框字体行高行宽
- 【转】CSRF基本概念
- 【转】UML类图符号 6种关系说明以及举例
- Linux操作_磁盘管理_增加虚拟磁盘
热门文章
- vue md5
- ArcGis dbf读写——挂接Excel到属性表 C#
- Ext.net MessageBox提示
- [Machine Learning] 浅谈LR算法的Cost Function
- string与number转换
- MVC实例应用模式
- tomcat 8.0安装ssl证书,及centos7.2 的openssl升级到最新版本,及ERR_SSL_OBSOLETE_CIPHER错误解决
- ps切图技巧
- 转:Spring历史版本变迁和如今的生态帝国
- Mysql 时间差(年、月、天、时、分、秒)