Vue学习之旅----父子路由-路由嵌套













import Vue from 'vue'
import Router from 'vue-router'
import VueResource from 'vue-resource'
import HelloWorld from '@/components/HelloWorld'
// 1 引入组件
import Home from '@/components/Home.vue'
import News from '@/components/News.vue'
import Content from '@/components/Content.vue'
import Pcontent from '@/components/Pcontent.vue'
import User from '@/components/User.vue'
import UserAdd from '@/components/User/UserAdd.vue'
import UserList from '@/components/User/UserList.vue'
Vue.use(Router)
Vue.use(VueResource)
export default new Router({
  // 配置路由
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld
    }, {
      path: '/home',
      name: 'Home',
      component: Home
    }, {
      path: '/news',
      name: 'News',
      component: News
    }, {
      // 动态路由
      path: '/content/:aid',
      name: 'Content',
      component: Content
    }, {
      path: '/pcontent',
      name: 'Pcontent',
      component: Pcontent
    }, {
      path: '/user',
      name: 'User',
      component: User,
      children: [
        {
          path: 'useradd',
          name: 'UserAdd',
          component: UserAdd
        },
        {
          path: 'userlist',
          name: 'UserList',
          component: UserList
        }
      ]
    }, {
      // 重定向
      path: '*',
      redirect: '/home'
    }
  ]
})

 

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