requirejs中shim使用
对不符合AMD规范的js脚本使用
shim
做导出配置,哪里不对?
demo:
https://github.com/xiaodongzai/demos/tree/gh-pages/requirejs_shim
<!-- index.html -->
<!DOCTYPE html>
<html>
<head lang="zh">
<meta charset="UTF-8">
<title>shim的使用</title>
</head>
<body>
<script src="./js/require.js" data-main="./js/app"></script>
</body>
</html>
//app.js
require.config({
baseUrl: "./js",
paths:{
'jquery': "jquery",
'log': 'log'
},
shim:{
'log':{
deps: ['jquery'],
exports: 'log'
}
}
});
require(['jquery','log'], function ($,log) {
log.writeLog('测试测试!!!');
});
//log.js
function writeLog(x){
document.write(x);
}
异常信息:
lu——舞
9 years, 6 months ago