我做了一個dojo構建,但我希望在啓用/禁用構建時具有靈活性,所以我試圖在<script>
標籤HTML頭:當從HTML標頭加載圖層時,Dojo構建在IE9上失敗:屬性'dir'未定義
<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上測試過)。問題是,這個屬性「目錄」是不確定的,在那個特定的代碼片段:
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...? What now?
所以我的問題是,我做錯了什麼,或者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
},
,這是從道場的運行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 %*
所以它似乎是,通過require加載圖層是正確的方式,並將其加載到腳本標記是一個伎倆,這不能保證工作? –
這絕對是我的經驗,是的。我不明白爲什麼會出現這種情況:我的理解是'