我已经制作了一个 dojo 构建,但我希望在启用/禁用构建时具有灵活性,所以我尝试<script>
在 HTML 标头中加载标签:
<script src="js/config.js"></script>
<script src="/dojo/1.9/dojo/dojo.js" data-dojo-config="async: true"></script>
<script src="/dojo/1.9/dojo/dojo-all.js"></script>
我没有修改我的 JS 文件。它似乎起作用,但是,有一个问题,但仅限于 IE9,并且仅限于部署在 WebSphere 上的应用程序版本(我已经在 Apache2 上测试过)。问题是,在那个特定的代码片段中,属性“dir”是未定义的:
geom.isBodyLtr = function isBodyLtr(doc) {
doc = doc || win.doc;
return (win.body(doc).dir || doc.documentElement.dir
|| "ltr").toLowerCase() == "ltr";
};
在搜索了一些类似的问题后(例如:How to prevent "Unable to get value of the property 'dir': object is null or undefined" error when loading pages in IE9),我检测到它可能是一些加载顺序问题。我已经从 HTML 标头中删除了该层,并按以下顺序将其加载到我的 JS 中:
require(["dojo/domReady!"], function(){
// load the layers, but only after document is ready
require(['dojo/dojo-all'], function(){
require(["dojo", "dojo/on", "dojo/dom-attr", "dojo/dom-class", (... and hundred more)
但是,我知道人们正在 HTML 标头中加载构建,例如从这里的主题:Dojo Builds...?现在怎么办?
所以我的问题是,我是不是做错了什么,或者 HTML 标头的技巧不能保证在所有浏览器上都有效?
这是我的构建脚本配置:
'dojo/dojo': {
include: ['dojo/dojo', 'dojo/domReady', 'dojo/_base/declare'],
boot: true,
customBase: true
},
'dojo/dojo-all': {
include: ["dojo/on", "dojo/dom-attr", "dojo/dom-class", "dojo/query", "dojo/_base/lang", "dojo/request/xhr",
"dijit/registry","dijit/form/TextBox", "dijit/form/Textarea", "dijit/form/ComboBox", "dijit/form/FilteringSelect", "dijit/form/CheckBox", "dijit/form/Button",
"gridx/core/model/cache/Sync", "gridx/Grid", "gridx/modules/SingleSort", "gridx/modules/ColumnResizer",
(...and hundred more)],
boot: false, // exclude bootstrap modules
customBase: false
},
这是dojo的build.bat:
java -Xms256m -Xmx256m -cp "%~dp0../shrinksafe/js.jar";"%
~dp0../closureCompiler/compiler.jar";"%~dp0../shrinksafe/shrinksafe.jar"
org.mozilla.javascript.tools.shell.Main "%~dp0../../dojo/dojo.js"
baseUrl="%~dp0../../dojo" load=build %*