2

大家好,感谢您的帮助!

我无法让 Dojo 需要寻找到 baseUrl 的相对路径。我的 tManager/pageList.js 对象所需的请求路径是“/tManager/pageList.js”,而它们应该是“js/tManager/pageList.js”。当我将“js/”添加到需要路径时它工作得很好,但我真的希望这些都是相对的。这是我的代码。

<script type="text/javascript">
var dojoConfig = {
    baseUrl: "js/",
    isDebug: true,
    tlmSiblingOfDojo: false,
    async: false,
    packages: [
        { name: "dojo", location: "lib/dojo" },
        { name: "dijit", location: "lib/dijit" },
        { name: "dojox", location: "lib/dojox" },
        { name: "tManager", location: "tManager/" }
    ]
};
</script>
<script type="text/javascript" src="js/lib/dojo/dojo.js"></script>
<script type="text/javascript">
require([
    "dojo/dom",
    "dojo/ready",
    "tManager/pageList.js"
], function (dom, ready, pageList) {
    ready(function () {
        alert("hello world");
    });
});
</script>

这是我的文件夹结构:
\
\js\
\js\lib\
\js\lib\dojo\
\js\lib\dijit\
\js\lib\dojox\
\js\tManager\

再次感谢您提前提供的帮助!

4

1 回答 1

3

假设您是 AMD 模块,请tManager/pageList.js摆脱. 否则,您将执行通用脚本注入而不是加载模块。.jsrequire

require([
    "dojo/dom",
    "dojo/ready",
    "tManager/pageList"  // <= do not use .js extension for AMD modules
], function (dom, ready, pageList) {
    ready(function () {
        alert("hello world");
    });
});
于 2012-09-22T17:50:21.900 回答