Vue.js +具有自己的路由文件的MPA

时间:2018-11-25 19:56:58

标签: javascript vue.js vue-router multi-page-application

当我尝试从src/Client/App.vue访问页面“ / admin / dashboard”加载页面时。我想用同一域中的不同vue,vuex,vue-router库将管理员和用户分开。可能吗? 我的项目树。

public/
 -> admin/
   -> index.html
 -> index.hmtl
src/
 -> Admin/
   -> components/
   -> admin.ts
   -> App.vue
   -> router.ts
 -> Client/
   -> components/
   -> admin.ts
   -> App.vue
   -> router.ts
 vue.config.js

src / Admin / router.ts

export default new Router({
  mode: 'history',
  base:   '/admin/', 
  routes: [
    {
      path: '/dashboard',
      name: 'dashboard',
      component: Dashboard,
    },
  ],
});

src / Client / router.ts

export default new Router({
  mode: 'history',
  base:  '/', 
  routes: [
    {
      path: '/',
      name: 'home',
      component: Home,
    },
  ],
});

vue.config.js

module.exports = {
    pages: {
        'admin': {
            entry: 'src/Admin/admin.ts',
            template: 'public/admin/index.html',
            filename: 'admin/index.html',
        },

        index: {
            entry: 'src/Client/main.ts',
            template: 'public/index.html',
            filename: 'index.html',
        },
    }
}

0 个答案:

没有答案