Vue二级路由嵌套以及多级路由嵌套思路
在router文件中的router.js中先
将一级路由注册
import Vue from 'vue'
import VueRouter from 'vue-router'
const routes = [
//这里是一级路由
{
path:'/index',
name:'index',
//路由懒加载
component:()=>import('../component/index.vue')
}
]
import Vue from 'vue'
import VueRouter from 'vue-router'
const routes = [
//这里写入一级路由名
{
path:'/index',
name:'index',
//路由懒加载
component:()=>import('../component/index.vue')
}
]
再将二级路由注册
import Vue from 'vue'
import VueRouter from 'vue-router'
const routes = [
//这里是一级路由
{
path:'/index',
name:'index',
//路由懒加载
component:()=>import('../component/index.vue'),
//children是写入子路由的意思
children:[
{
path:'/home',
name:'home',
component:()=>import