官网地址:https://router.vuejs.org/zh-cn/essentials/nested-routes.html

路由嵌套一般使用在后台管理系统中

给一个比较简单的小案例

<!DOCTYPE html>
<html lang="en"> <head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdn.bootcss.com/vue/2.5.16/vue.js"></script>
<script src="https://cdn.bootcss.com/vue-router/3.0.1/vue-router.js"></script>
<style>
.layout {
width: 600px;
margin: 100px auto;
} .left {
width: 200px;
height: 500px;
float: left;
border: 1px solid red;
} .right {
width: 380px;
height: 500px;
float: right;
border: 1px solid green;
} .top {
height: 100px;
border: 1px solid black;
}
</style>
</head>
<script type="text/html" id="templateId">
<div class="layout">
<div class="left">左边菜单<br/><br/>
<router-link to="/menu1/login">登录组件</router-link><br/><br/>
<router-link to="/menu1/register">注册组件</router-link>
</div>
<div class="right">
<div class="top">
顶部内容
</div>
<div class="content">
<br/>
<router-view></router-view>
</div>
</div>
</div>
</script> <body>
<div id="app">
<router-link to="/menu1">菜单1</router-link>
<router-link to="/menu2">菜单2</router-link> <router-view></router-view>
</div>
</body>
<script>
//1、注册组件
const menu1 = {
template:"#templateId"
} const menu2 = {
template:'<div>我是菜单2</div>'
} const login = {
template:'<div>我是登录组件</div>'
} const register = {
template:'<div>i am register components</div>'
} //2、创建路由对象,设置路由规则
const router = new VueRouter({
routes:[
{
path:'/menu1',
component:menu1,
children:[
{path:'login',component:login},
{path:'register',component:register}
]
},
{
path:'/menu2',
component:menu2
}
]
}) new Vue({
el: "#app",
router
})
</script> </html>

VUE中嵌套路由的更多相关文章

  1. vue中的路由的跳转的参数

    vue中的路由跳转传参 params 与 query this.$router.push({ name:"detail", params:{ name:'nameValue', c ...

  2. vue中嵌套页面 iframe 标签

    vue中嵌套iframe,将要嵌套的文件放在static下面: <iframe src="../../../static/bear.html" width="300 ...

  3. vue中嵌套页面(iframe)

    vue中嵌套iframe,将要嵌套的文件放在static下面.(要将打包文件整体放在statici里,我的文件名是canvas) src可以使用相对路径,也可使用服务器根路径http:localhos ...

  4. vue中嵌套的iframe中控制路由的跳转及传参

    在iframe引入的页面中,通过事件触发的方式进行传递参数,其中data是一个标识符的作用,在main.js中通过data进行判断,params是要传递的参数 //iframe向vue传递跳转路由的参 ...

  5. vue中的路由独享守卫的理解

    1.vue中路由独享守卫意思就是对这个路由有一个单独的守卫,因为他的守卫方式于其他的凡是不太同 独享守卫于前置守卫使用方法大致是一样的 在路由配置的时候进行配置, { path:'/login', c ...

  6. vue.js嵌套路由-------由浅入深

    嵌套路由就是路由里面嵌套他的子路由 子路由关键属性children 每一个子路由里面可以嵌套多个组件 子组件又有路由导航和路由容器 <router-link to="/父路由的地址名字 ...

  7. vue 中的路由为什么 采用 hash 路由模式,而不是href超链接模式(Hypertext,Reference)?

    1. vue中路由模式的种类有两种 1. 一种是 hash 模式. 2. 一种是 h5 的 history 模式. 2. hash 和 history 都是来自 bom 对象 bom 来自 windo ...

  8. Vue中的路由 以及默认路由跳转

    https://router.vuejs.org/ vue路由配置: 1.安装 npm install vue-router --save / cnpm install vue-router --sa ...

  9. vue中的路由嵌套

    1定义组件 const Index = { template:` <div>首页</div> ` } const Order = { template:` <div> ...

随机推荐

  1. 关于对H264码流的PS的封装的相关代码实现

    1.写在开始之前: 最近因为新工作要维护别人留下的GB模块代码,先熟悉了流程,然后也试着封装了下ps流,结果也能通过测试正常预览了,当然,其中开发读文档的头疼,预览花屏,卡帧的事情都有遇到,当时慢慢的 ...

  2. CodeForces Gym 100228 Graph of Inversions

    题目大意 对于一个长为$N$的序列$A$,定义它所对应的逆序图: 有$N$个点组成,标号为$1...N$的无向图,对于每一组$i,j(i<j)$若存在$A_i>A_j$则在新图中就存在一条 ...

  3. codeforces914G Sum the Fibonacci

    题目大意:给定一个长为$n$($n\leq 10^6$)的序列S,定义一个合法的五元组$(a,b,c,d,e)$合法当且仅当 $$ ( S_a \mid S_b ) and S_c and ( S_d ...

  4. 使用UIVisualEffectView创建毛玻璃效果

    UIVisuaEffectView :继承自UIView,可以看成是专门用于处理毛玻璃效果的视图,只要我们将这个特殊的View添加到其他视图(eg. ImageView )上面,被该UIVisuaEf ...

  5. bzoj 2850 巧克力王国——KDtree

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2850 改一下估价即可.判断子树能否整个取或者是否整个不能取,时间好像就能行了? 因为有负数, ...

  6. rsync同步文件,排除多个文件/目录

    使用rsync -aP --exclude=upload 只能排除upload文件/目录.如果要排除多个文件/目录,怎么办?  那只能建一个exclude.list,里面填写要排除的目录(一行一个文件 ...

  7. CCS V5 使用教程三:程序调试

    官网教程 新建调试工程 输入以下源码: #include <stdio.h> #include <c6x.h> ]; void main(void) { unsigned ; ...

  8. 杂项-权限管理:Ralasafe

    ylbtech-杂项-权限管理:Ralasafe Ralasafe 是用Java编写的开源(MIT协议)访问控制中间件.它能够轻松处理登录控制.URL权限控制和(业务级)数据级权限管理,实现权限与业务 ...

  9. warning no newline at the end of file

    main.c :10:2 warning: no newline at the end of file 修复这个警告,在文件结尾回车一下就行了.可以很少会有人去仔细探究,为什么gcc会给出这么一个警告 ...

  10. Learning Python 005 字符串和编码

    Python 字符串和编码 介绍 计算机是美国人发明的,最早只有127个字母被编码到计算机,这个编码表被称为ASCII编码,比如大写字母A的编码是65,小写字母z的编码是122. 处理中文一个字节显然 ...