美文网首页
14. 基于Vue+Element+nodeJs+Express

14. 基于Vue+Element+nodeJs+Express

作者: 竹立荷塘 | 来源:发表于2020-05-05 23:34 被阅读0次

    在main.js同级目录下创建router.js文件用来管理路由:
    我这里的路由采用的是history模式:

    import Vue from 'vue'
    import Router from 'vue-router'
    
    Vue.use(Router)
    
    const originalPush = Router.prototype.push
    Router.prototype.push = function push (location) {
      return originalPush.call(this, location).catch(err => err)
    }
    
    export default new Router({
      mode: 'history',
      base: process.env.BASE_URL,
      routes: [
        {
          path: '/',
          name: 'login',
          component: () => import('./views/Login.vue'),
          meta: { pagePath: '/' }
        },
        {
          path: '/home',
          name: 'home',
          component: () => import(/* webpackChunkName: "home" */ './views/Home.vue'),
          meta: { pagePath: '/home' },
          children: [
            {
              path: 'user',
              name: 'user',
              component: () => import(/* webpackChunkName: "user" */ './views/User/User.vue'),
              meta: { pagePath: '/home/user' }
            },
            {
              path: 'weekly',
              name: 'weekly',
              component: () => import(/* webpackChunkName: "weekly" */ './views/Weekly/Weekly.vue'),
              meta: { pagePath: '/home/weekly' }
            },
            {
              path: 'weeklyadd',
              name: 'weeklyadd',
              component: () => import(/* webpackChunkName: "weekly" */ './views/Weekly/childViews/WeeklyAdd.vue'),
              meta: { pagePath: '/home/weekly' }
            },
            {
              path: 'weeklyedit',
              name: 'weeklyedit',
              component: () => import(/* webpackChunkName: "weekly" */ './views/Weekly/childViews/WeeklyEdit.vue'),
              meta: { pagePath: '/home/weekly' }
            },
            {
              path: 'weeklydetail',
              name: 'weeklydetail',
              component: () => import(/* webpackChunkName: "weekly" */ './views/Weekly/childViews/WeeklyDetail.vue'),
              meta: { pagePath: '/home/weekly' }
            }
          ]
        },
        {
          path: '/refresh',
          component: () => import(/* webpackChunkName: "home" */ './views/Refresh.vue'),
          name: 'Refresh'
        }
      ]
    })
    
    

    项目体验链接

    周报管理系统体验链接: https://www.17sucai.com/pins/35488.html

    相关文章

      网友评论

          本文标题:14. 基于Vue+Element+nodeJs+Express

          本文链接:https://www.haomeiwen.com/subject/duybghtx.html