我想,所以我改變了這種從舊dojo.require裝載到新的AMD裝載機遷移:如何從舊的dojo遷移到新的dojo AMD加載器?
dojo.require("dojo._base.xhr");
dojo.require("dojox.mobile.parser");
dojo.require("dojox.mobile");
dojo.require("dojox.mobile.ScrollableView");
dojo.require("dojox.mobile.TabBar");
dojo.require("dojox.mobile.TextBox");
dojo.require("dojox.mobile.compat");
dojo.require("dojox.mobile.deviceTheme");
dojo.require("dojox.mobile.TabBarButton");
dojo.require("dojox.mobile.View");
dojo.require("dojox.mobile.Button");
dojo.require("dojox.mobile.Switch");
dojo.require("dojo.on");
dojo.require("dijit.registry");
dojo.require("dojo.aspect");
dojo.require("dojo.ready");
dojo.require("dojox.mobile.ListItem");
dojo.require("dojo.dom");
dojo.require("dojo.request");
dojo.require("dojo.dom-construct");
dojo.require("dojo.domReady!");
CODE
這樣:
require(["dojo/_base/xhr","dojox/mobile/parser","dojox/mobile","dojox/mobile/ScrollableView","dojox/mobile/TabBar","dojox/mobile/TextBox","dojox/mobile/compat","dojox/mobile/deviceTheme","dojox/mobile/TabBarButton","dojox/mobile/View","dojox/mobile/Button","dojox/mobile/Switch","dojo/on","dijit/registry","dojo/aspect","dojo/ready","dojox/mobile.ListItem","dojo/dom","dojo/request","dojo/dom-construct","dojo/domReady!"],
function(xhr,parser,mobile,ScrollableView,TabBar,TextBox,compat,deviceTheme,TabBarButton,View,Button,Switch,on,registry,aspect,ready,ListItem,dom,request){CODE})
的是,這樣做是正確的? 我有一些其他腳本文件,我簡單加載如何使用新的AMD加載器來處理它們?
我非常新的所有編程的東西,所以請以軟我:)
看起來很好。這裏有更詳細的說明 - http://dojotoolkit.org/reference-guide/1.7/releasenotes/migration-2.0.html。最後的測試是...它工作嗎?!我也認爲這是XHR的新方法 - http://dojotoolkit.org/reference-guide/1.8/dojo/request/xhr.html#dojo-request-xhr。 – 2013-04-25 11:59:26