• 配置动态加载模块和js分模块打包,生产环境和开发环境公共常量配置


    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}
    

      

        

  • 相关阅读:
    后端分页但是前端想要把所有数据取出来
    css做多列瀑布流
    css制作骰子
    css球体
    css摩天轮
    css圆圈慢慢放大
    01-布局扩展-自适应两栏布局
    Zigbee 知识简介
    华为OD 嵌入式方向面经
    算法练习题 2 合唱队
  • 原文地址:https://www.cnblogs.com/Mvloveyouforever/p/8316935.html
Copyright © 2020-2023  润新知