globals.js文件:
define(function(require) {
"use strict";
return {
"libsPath": "../../"
};
});
index.html文件:
<script>
var require = {
deps: ["js/globals"],
callback: function(Globals) {
libsPath = Globals.libsPath;
console.log(libsPath);
}
};
</script>
<script data-main="main.js" src="libs/require.js" type="text/javascript"></script>
main.js文件:
require.config({
baseUrl: './js/',
paths: {
'jquery': '../../libs/jquery'
}
});
我想在我的require.config选项中使用libsPath作为全局变量,如下所示:类似require.libsPath
require.config({
baseUrl: './js/',
paths: {
'jquery': require.libsPath + 'libs/jquery'
}
});
有没有办法实现这个目标?简而言之;如何在main.js配置中使用require全局变量?