花狐貂
2016-05-19 16:22
html:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript" src="js/require.js" data-main="js/main"></script>
</body>
</html>
main.js:
requirejs.config({
paths:{
jquery:'jquery.min'
}
});
requirejs(['jquery','validate'],function($,validate){
console.log(validate.isEqual(1,2));
});
validate.js:
define(['jquery',function($){
return{
isEmpty:function(){},
checkLength:function(){alert("11");},
isEqual:function(str1,str2){
return str1===str2;
}
};
}]);
define(['jquery',function($){这个地方少一个方括号:
这个地方改成:define(['jquery'],function($){
return { isEmpty:function(){},
isEqual:function(){},
checkLength:function(){}
}
}
侧栏工具条开发
68226 学习 · 289 问题
相似问题