Vue配置路由

111 阅读1分钟
import Login from '@/views/login/Login.vue'
import Layout from '@/views/layout/Layout.vue'
import Home from '@/views/home/Home.vue'
import Shop from '@/views/shop/Shop.vue'
import AccountList from '@/views/account/List.vue'
import AccountAdd from '@/views/account/Add.vue'
import AccountModify from '@/views/account/Modify.vue'
import Personal from '@/views/account/Personal.vue'
import GoodsList from '@/views/goods/List.vue'
import GoodsAdd from '@/views/goods/Add.vue'
import GoodsCate from '@/views/goods/Cate.vue'
import Order from '@/views/order/Order.vue'
import GoodsTotal from '@/views/sales/GoodsTotal.vue'
import OrderTotal from '@/views/sales/OrderTotal.vue'
const routes = [
  {
   path:'/',
   redirect:'/login'
  },
  
  {
    path:'/login',
    component: Login,
  },
  {
    path:'/home',//layout/home
    component: Layout,
    children: [
      {path: '', component: Home}//layout
    ]
  },
  {
    path:'/shop',
    component: Layout,
    children: [
      {path: '', component: Shop}
    ]
  },
  {
    path:'/account',
    component: Layout,
    redirect: '/account/list',
    children:[
      { path:'/account/list', component: AccountList,},
      { path:'/account/add', component: AccountAdd,},
      { path:'/account/modify', component: AccountModify,},
      { path:'/account/personal', component: Personal,}
    ]
  },
  {
    path:'/goods',
    redirect: '/goods/list',
    component: Layout
    children:[
      { path: '/goods/list', component: GoodsList,},
      { path: '/goods/add', component: GoodsAdd,},
      { path: '/goods/cate', component: GoodsCate,}
    ]
  },
  {
    path:'/order',
    component: Layout,
    children: [
      {path: '', component: Order}
    ]
  },
  {
    path:'/sales',
    component: Layout,
    redirect:'/sales/goods-total',
    children: [
      {path: '/sales/goods-total', component: GoodsTotal},
      {path: '/sales/order-total', component: OrderTotal}
    ]
  },
]