配置动态加载模块和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}
配置动态加载模块和js分模块打包,生产环境和开发环境公共常量配置的更多相关文章
- js动态加载css和js
之前写了一个工具类点此链接里面含有这段代码,感觉用处挺多,特意提出来 var loadUtil = { /* * 方法说明:[动态加载js文件css文件] * 使用方法:loadUtil.loadjs ...
- 用JavaScript动态加载CSS和JS文件
本文转载自:http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/11/14/2248451.html 今天项目中需要用到动态加载 CSS 文件 ...
- 动态加载 移除js file
动态加载.移除.替换js/css文件 stylesheetjavascriptcssfunctionnull <script language="javascript"> ...
- JavaScript动态加载资源【js|css】示例代码
在开发过程中会用到各种第三方的插件,或者自己写在单独文件中的js方法库或者css样式,在html头部总是需要写一大堆的script和link标签,如果想要自己实现动态的引入资源文件,可以使用开源的re ...
- js实用方法记录-js动态加载css、js脚本文件
js实用方法记录-动态加载css/js 附送一个加载iframe,h5打开app代码 1. 动态加载js文件到head标签并执行回调 方法调用:dynamicLoadJs('http://www.yi ...
- JavaScript动态加载CSS和JS文件
var dynamicLoading = { css: function(path){ if(!path || path.length === 0){ throw new Error('argumen ...
- .NET Web后台动态加载Css、JS 文件,换肤方案
后台动态加载文件代码: //假设css文件:TestCss.css #region 动态加载css文件 public void AddCss() { HtmlGenericControl _CssFi ...
- 动态加载css、js引用
在js代码中动态的加载js.css文件的引用 function addJsCssByLink(type,url) { var doc=document; if(type="js") ...
- 动态加载CSS,JS文件
var Head = document.getElementsByTagName('head')[0],style = document.createElement('style'); //文件全部加 ...
随机推荐
- 如何插入sql数据
原:http://blog.csdn.net/Weicleer/article/details/47608289
- Spring 入门 web.xml配置详解
Spring 入门 web.xml配置详解 https://www.cnblogs.com/cczz_11/p/4363314.html https://blog.csdn.net/hellolove ...
- async 和 await的前世今生 (转载)
async 和 await 出现在C# 5.0之后,给并行编程带来了不少的方便,特别是当在MVC中的Action也变成async之后,有点开始什么都是async的味道了.但是这也给我们编程埋下了一些隐 ...
- c++ 查找容器中不满足条件的元素,返回iterator(find_if_not)
#include <iostream> // std::cout #include <algorithm> // std::find_if_not #include <a ...
- CTO详细讲解海量日志处理ELK
ELK实时日志分析平台之Elasticsearch简介 Elasticsearch是一个高度灵活的开源全文检索和分析引擎.它能够迅速(几乎是实时地)地存储.查找和分析大规模数据.通常被用在有复杂的搜索 ...
- Android JNI学习(四)——JNI的常用方法的中文API
本系列文章如下: Android JNI(一)——NDK与JNI基础 Android JNI学习(二)——实战JNI之“hello world” Android JNI学习(三)——Java与Nati ...
- Codeforces 294D - Shaass and Painter Robot
294D - Shaass and Painter Robot 思路: 可以用数学归纳法证明一个结论:整个棋盘黑白相间当且仅当边缘黑白相间. 分奇偶讨论又可得出边缘黑色格个数为n+m-2 这样就可以暴 ...
- 测试工作中经常用到的一丢Linux命令
自己平时测试工作中经常要在Linux下搭建测试环境,有涉及到启动/终止服务器,修改tomcat配置文件,偶尔碰到端口被占用... 这时就不得不需要一些基本的Linux命令来处理遇到的这些问题 1.cd ...
- English trip -- Review Unit 10 Leisure 休闲
Words dance exercise fish play basketball play cards swim cook play the guitar listen to music watch ...
- php--------ThinkPHP3.2验证码使用
Thinkphp框架验证码的路径目录:ThinkPHP -> Library -> Think -> Verify.class.php ,只要在控制器中实例化这个类就能实现验证码的功 ...