1. 在路由文件 router --> index.js中,设置base:'/内部设置的词汇/',会同步在网页地址的前端
2.嵌套路由:在router --> index.js中,设置新增单个路由属性childron,为数组,内部放入的单路由为该路由的子路由
1 import Vue from 'vue; 2 import VueRouter from 'vue-router'; 3 Vue.use(VueRouter); 4 5 6 const routes = [ 7 8 {path:'/A', //组件A 9 component:()=>import('@/components/A), 10 children:[ 11 {path;‘a’,conponent:()=>import('@/components/A/a'), //组件A中的小组件a,路由地址是/A/a 12 {path;‘b’,conponent:()=>import('@/components/A/b'),//组件A中的小组件b,路由地址是/A/b 13 ] 14 redirect:‘/A/a’ //进入A组件的时候自动进入a组件 15 } 16 {path:'/B', //组件B 17 component:()=>import('@/components/B')} 18 ]; 19 20 const router = new VueRouter({ 21 routes 22 }) 23 24 export default router; //向mian.js中输出router