vuerouter-3.路由嵌套
1.动态路由(参数传递)
/:id
2.路由嵌套
import Vue from 'vue'
import VueRouter from 'vue-router'
//@表示寻找根目录
import HelloWorld from '@/components/HelloWorld'
import learn from '@/components/learn'
import Basee from '@/components/basee'
import Http from '@/components/http'
Vue.use(VueRouter)
//创建路由
export default new VueRouter({
routes: [{
path: "/h",
name: "HelloWorld", //可以作为跳转使用
component: HelloWorld
},
{
path: "/learn",
name: "learn",
component: learn,
children: [{
path: "basee",
component: Basee
},
{
path: "http",
component: Http
}
]
}
]
})
3.learn.vue
<template>
<div class="learn">learn
<!-- {{this.$route.params.id}} -->
<ul>
<router-link to="/learn/basee" tag="li">基本学习</router-link>
<router-link to="/learn/http" tag="li">网络学习</router-link>
</ul>
<router-view />
</div>
</template>
<script>
export default {
/* name:"learn" */
}
</script>
<style>
</style>