Vue路由之间传参,子路由设置

路由传参

  1. params传参
    index.js导入组件,注册路由
    import JobMess from '@/components/JobMess'
    {
      path: '/job', //如果想在地址url上显示加上:path:'/job/:id'
      name: 'jobmess',
      component: JobMess
    },
    
    路由跳转
    跳转
    
    JobMess.vue接收参数
    
    
  2. query传参
    index.js导入组件,注册路由
    import JobMess from '@/components/JobMess'
    {
      path: '/job',
      name: 'jobmess',
      component: JobMess
    },
    
    路由跳转
    //query的内容会在url上显示
    跳转
    
    JobMess.vue上接收参数
    
    

注册二级路由

  1. index.js中注册

    export default new Router({
    	routes:[
    		{
          path: '/',
          name: 'index',
          component: Index,
          children:[
          {
          	path:'a1',  //注意:这里path不要加/
          	name:'child',
          	component:Child
          	}
          ]
        	},
    	]
    })
    
  2. 在父路由的组件里

你可能感兴趣的:(笔记)