“可移植模块”适用于src版本,但不适用于预构建版本

时间:2013-04-13 00:23:08

标签: dojo

为了将dojo 1.8与1.6结合使用,我按照教程Defining Modules中的描述,在“使用便携式模块”子标题下设置了可移植模块。

我一直在使用dojo的源代码版本,“dojo-release-1.8.3-src.zip”,它运行得很好,但当我切换到预建版本时,“dojo- release-1.8.3.zip“,它会引发404错误,寻找依赖关系:

GET http://localhost:8080/sb/javascript/lib/dojo-release-1.8.3/dojo/parser.js     200 OK
GET http://localhost:8080/sb/javascript/lib/dojo-build-1.6.1/dojo/_base/url.js    404 Not Found
"NetworkError: 404 Not Found - http://localhost:8080/sb/javascript/lib/dojo-build-1.6.1/dojo/_base/url.js"

GET http://localhost:8080/sb/javascript/lib/dojo-release-1.8.3/dojo/request.js    200 OK
GET http://localhost:8080/sb/javascript/lib/dojo-build-1.6.1/dojo/request/default.js     404 Not Found
"NetworkError: 404 Not Found - http://localhost:8080/sb/javascript/lib/dojo-build-1.6.1/dojo/request/default.js"

从控制台可以清楚地看到,它正在查找依赖文件的错误位置(查看'dojo-build-1.6.1'而不是'dojo-release-1.8.3')。我想知道的是为什么?我所做的就是将源版本换成预先构建的版本。

这是我的配置:

<script>
    var map18 = {dojo: "dojo18", dijit: "dijit18", dojox: "dojo18"};
    var dojoConfig = {
        async: false,
        parseOnLoad: true,  // in 1.8 they suggest setting to false and manually parsing when needed, but we're not set up that way at the moment
        packages: [
            {name: "dgrid", location: "../../dgrid/dgrid", packageMap: map18},
            {name: "xstyle", location: "../../dgrid/xstyle", packageMap: map18},
            {name: "put-selector", location: "../../dgrid/put-selector", packageMap: map18},
            {name: "modules", location: "../../modules", packageMap: map18},
            {name: "page", location: "../../page"},
            {name: "dojoc", location: "../../dojoc"},
            {name: "dojo18", location: "../../dojo-release-1.8.3/dojo", packageMap: map18},
            {name: "dijit18", location: "../../dojo-release-1.8.3/dijit", packageMap: map18},
            {name: "dojox18", location: "../../dojo-release-1.8.3/dojox", packageMap: map18},
            {name: "dojo", location: "../../dojo-build-1.6.1/dojo", main: "dojo"},
            {name: "dijit", location: "../../dojo-build-1.6.1/dijit"},
            {name: "dojox", location: "../../dojo-build-1.6.1/dojox"}
        ],
    };
</script> 

1 个答案:

答案 0 :(得分:0)

我尝试过类似的东西(使用1.8和1.6源代码)并得到了不同的错误。我知道这不是问题的答案,但我会把它贴在这里,以防它帮你找到答案。

这是我的测试页:

<script>
var location18 = "/dojo18";
var location16 = "/dojo16";
var map16 = { dojo: "dojo16", dijit: "dijit16", dojox: "dojox16" },
    dojoConfig = {
        packages: [
            { name: "dojo16", location: location16 + "/dojo", packageMap: map16 },
            { name: "dijit16", location: location16 + "/dijit", packageMap: map16 },
            { name: "dojox16", location: location16 + "/dojox", packageMap: map16 },
            { name: "dojo", location: location18 + "/dojo" },
            { name: "dijit", location: location18 + "/dijit" },
            { name: "dojox", location: location18 + "/dojox" }
        ]
    };
</script>
<script src="/dojo18/dojo/dojo.js"></script>
<script>
require(["dojo/date"], function (date) {
    console.log("date18", date);
});
</script>
<script>
require(["dojo16/date"], function (date) {
    console.log("date16", date);
});
</script>

我得到的错误似乎与加载两个日期模块有关。不确定Dojo是否可以单独处理它们,但我还没有设法做到这一点。

Error