1、 话不多少 先上代码: route.js
// 引用模板 分模块编译 const main = r => require.ensure([], () => r(require('../page/main.vue')), 'main') const home = r => require.ensure([], () => r(require('../page/main.home.vue')), 'home') const userSpace = r => require.ensure([], () => r(require('../page/main.userSpace.vue')), 'userSpace') const live = r => require.ensure([], () => r(require('../page/main.live.vue')), 'live') const lesson = r => require.ensure([], () => r(require('../page/main.lesson.vue')), 'lesson') const teaching = r => require.ensure([], () => r(require('../page/main.teaching.vue')), 'teaching') const systemManagement = r => require.ensure([], () => r(require('../page/main.application.vue')), 'userSpace') // 系统管理 const platformInfor = r => require.ensure([], () => r(require('../page/systemManagement/system.platformInfor.vue')), 'platformInfor') const platformEmail = r => require.ensure([], () => r(require('../page/systemManagement/system.platformEmail.vue')), 'userSpace') // 配置路由 export default [ // 双路由都可跳转到 home { path: '/', redirect: '/home', component: main, children: [ { path: 'home', component: home }, { path: 'userSpace', component: userSpace }, ] }, // 双路由都可跳转到 home { path: '/:code/', // path前边添加可变路由 redirect: '/:code/home', component: main, children: [ { path: 'home', component: home }, { path: 'userSpace', component: userSpace }, { path: 'live', component: live }, { path: 'lesson', component: lesson, children: [ ] }, { path: 'teaching', component: teaching }, { path: 'systemManagement/', component: systemManagement, redirect: 'systemManagement/setUp/platformInfor', children:[ { path: 'setUp/platformInfor', component: platformInfor, }, { path: 'setUp/platformEmail', component: platformEmail } ] } ], } ]
2、global_config.js
const Domain = { location: window.location, href: window.location.href, protocol: window.location.protocol, host: window.location.host, hostname: window.location.hostname, port: window.location.port, search: window.location.search, hash: window.location.hash } let baseURL // 配置开发环境和线上生产环境的切换 if (process.env.NODE_ENV == 'development') { baseURL = 'http://192.168.12.54:8080/'; } else if (process.env.NODE_ENV == 'production') { baseURL = '/'; } export {Domain, baseURL}