-
Notifications
You must be signed in to change notification settings - Fork 1
/
m.js
64 lines (61 loc) · 2.21 KB
/
m.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* Created by JetBrains WebStorm.
* User: yinkehao
* Date: 12-6-7
* Time: 上午9:17
* To change this template use File | Settings | File Templates.
*/
/** 按照module版本进行模块加载,在模块版本未指定时,使用默认版本,默认版本*/
define({
version:"1.0.0",
normalize: function (name, normalize) {
var minfo = name.split(":"),
modelpath = (normalize(minfo[0]));
if(minfo[1]){
minfo[1] = normalize(minfo[1]).replace(/_unnormalized\d+/gi,"")
var modelname = modelpath.split("/"),version = minfo[1]
modelpath+="/"+version+"/"+modelname[modelname.length-1]
}
if(/^\//.test(modelpath)){
modelpath+=".js"
}
return modelpath;
},
load:function(name,req,load,config){
if(name==""){
load()
return
}
require([name],function(m){
load(m)
},function(err){
// console.log(err)
throw err
return
if(err.requireModules){
// console.log(err.requireType)
$.each(err.requireModules,function(i,errm){
if(err.requireType=="scripterror"){
alert("模块:"+ errm + "不存在")
//throw new Error("模块:"+ errm + "不存在")
}
if(err.requireType=="define"){
// alert("模块:"+ errm + "错误")
if(typeof console!= "undefined"&& typeof console.log!= "undefined"){
console.log(err.stack)
}else{
require(["./widget/jbox"],function(jbox){
jbox(err.stack.replace(/\n/,"<br>"),{
title:"javascript 错误:模块"+errm,
width:800
})
})
}
//throw new Error("模块:"+ errm + "不存在")
}
requirejs.undef(errm);
})
}
})
}
})