【发布时间】:2013-02-07 18:21:08
【问题描述】:
我查找了重复的问题,但没有准确找到。这个和Dojo require() and AMD (1.7)有关,不过我会以提问的形式提问。问题是,为什么我会收到这个错误,为什么 dijit 在 firebug 中显示“3”?
JSP 页面
<script type="text/javascript" src="<%= request.getContextPath() %>/js/dojoConfig.js"></script>
<script type="text/javascript"
src="http://xxxxxxxxxxxxx.com/dojo/1.7.2/dojo/dojo.js.uncompressed.js"></script>
<script type="text/javascript" src="<%= request.getContextPath() %>/js/reviewframe.js"></script>
dojoConfig.js
var dojoConfig = {
// Use the Asynchronous AMD loader.
// --------------------------------
async : true,
// Use debug.
// --------------------------------
isDebug : true,
// Parse the html on load for dojo rendered elements.
// Don't Parse on Load. I'm calling it manually in my main pageLoad.
// --------------------------------
parseOnLoad : false,
};
reviewframe.js(我的“主要”)
require(
[ "dojo", "dijit", "dojo/parser", "js/XYDialog.js",
"dijit/layout/ContentPane", "dojox/image/LightboxNano", "dojo/ready",
"dojo/domReady!" ],
function(dojo, dijit, parser, XYDialog) {
XYDialog.js
define([ "dojo", "dijit", "dijit/form/Button", "dijit/TooltipDialog",
"dijit/form/DropDownButton", "dijit/form/FilteringSelect" ], function(
dojo, dijit) {
我在上面定义的 XYDialog.js 中设置了一个断点。我点击继续,我在控制台中收到此错误:
控制台
focus.js line 382
TypeError: can't convert undefined to object [Break On This Error] ...attr] = typeof singleton[attr] == "function" ? lang.hitch(singleton, attr) : sin...
如果我在 focus.js 中在那一行之前设置一个 Firebug 断点,我会看到 dijit 是数字 3。为什么?我以前在其他地方看到过这种情况,我需要的 javascript 或模块最终是数字 3。
编辑: 我的天啊,我关闭了 Firefox 并加载了没有萤火虫的页面。有用!然后我打开了萤火虫,清除了所有断点,它又可以工作了。嘘。
后续问题: firebug 中的断点会破坏 AMD 加载程序吗?毕竟是异步的。您的断点可能会引入时间问题...
【问题讨论】:
标签: javascript dojo firebug amd