📄 debugging tutorial the dojo toolkit.mht
字号:
class=3Dkw2>></SPAN></SPAN><BR> =20
@import =
"/dojoroot/dijit/themes/tundra/tundra.css";<BR> =20
@import =
"/dojoroot/dojo/resources/dojo.css"<BR> =20
<SPAN class=3Dsc2><SPAN =
class=3Dkw2></style></SPAN></SPAN><BR> =20
<SPAN class=3Dsc2><A=20
href=3D"http://december.com/html/4/element/script.html"><SPAN=20
class=3Dkw2><script</SPAN></A> <SPAN class=3Dkw3>type</SPAN>=3D<SPAN=20
class=3Dst0>"text/javascript"</SPAN> <SPAN =
class=3Dkw3>src</SPAN>=3D<SPAN=20
class=3Dst0>"/dojoroot/dojo/dojo.js"</SPAN> <BR> =
=20
djConfig=3D<SPAN class=3Dst0>"parseOnLoad: true"</SPAN><SPAN=20
class=3Dkw2>></SPAN></SPAN><SPAN class=3Dsc2><SPAN=20
class=3Dkw2></script></SPAN></SPAN><BR> <SPAN =
class=3Dsc2><A=20
href=3D"http://december.com/html/4/element/script.html"><SPAN=20
class=3Dkw2><script</SPAN></A> <SPAN class=3Dkw3>type</SPAN>=3D<SPAN=20
class=3Dst0>"text/javascript"</SPAN><SPAN =
class=3Dkw2>></SPAN></SPAN><BR> =20
dojo.require("dojo.parser");<BR> =
=20
dojo.require("dojobook.online-book.debugging.BuggyWidget");<BR> =
=20
<SPAN class=3Dsc2><SPAN =
class=3Dkw2></script></SPAN></SPAN><BR><SPAN=20
class=3Dsc2><SPAN class=3Dkw2></head></SPAN></SPAN><BR><SPAN =
class=3Dsc2><A=20
href=3D"http://december.com/html/4/element/body.html"><SPAN=20
class=3Dkw2><body</SPAN></A> <SPAN class=3Dkw3>class</SPAN>=3D<SPAN=20
class=3Dst0>"tundra"</SPAN><SPAN =
class=3Dkw2>></SPAN></SPAN><BR> =20
<SPAN class=3Dsc2><A =
href=3D"http://december.com/html/4/element/div.html"><SPAN=20
class=3Dkw2><div</SPAN></A> dojoType=3D<SPAN=20
class=3Dst0>"dojobook.online-book.debugging.BuggyWidget"</SPAN><SPAN=20
class=3Dkw2>></SPAN></SPAN><SPAN class=3Dsc2><SPAN=20
class=3Dkw2></div></SPAN></SPAN><BR><SPAN class=3Dsc2><SPAN=20
class=3Dkw2></body></SPAN></SPAN><BR><SPAN class=3Dsc2><SPAN=20
class=3Dkw2></html></SPAN></SPAN></DIV>
<DIV class=3Dgeshifilter style=3D"FONT-FAMILY: monospace">dojo.<SPAN=20
class=3Dme1>provide</SPAN><SPAN class=3Dbr0>(</SPAN><SPAN=20
class=3Dst0>"dojobook.online-book.debugging.BuggyWidget"</SPAN><SPAN=20
class=3Dbr0>)</SPAN>;<BR class=3Dgeshibr>dojo.<SPAN =
class=3Dme1>require</SPAN><SPAN=20
class=3Dbr0>(</SPAN><SPAN class=3Dst0>"dijit._Widget"</SPAN><SPAN=20
class=3Dbr0>)</SPAN>;<BR class=3Dgeshibr>dojo.<SPAN =
class=3Dme1>declare</SPAN><SPAN=20
class=3Dbr0>(</SPAN><BR><SPAN=20
class=3Dst0>"dojobook.online-book.debugging.BuggyWidget"</SPAN>,<BR><SPAN=
=20
class=3Dbr0>[</SPAN>dijit._Widget<SPAN class=3Dbr0>]</SPAN>,<BR><SPAN=20
class=3Dbr0>{</SPAN> <BR> postCreate: <SPAN=20
class=3Dkw2>function</SPAN><SPAN class=3Dbr0>(</SPAN><SPAN =
class=3Dbr0>)</SPAN> <SPAN=20
class=3Dbr0>{</SPAN><BR> dojo.<SPAN=20
class=3Dme1>nonExistentMethod</SPAN><SPAN class=3Dbr0>(</SPAN><SPAN=20
class=3Dbr0>)</SPAN>;<BR> <SPAN =
class=3Dbr0>}</SPAN><BR><SPAN=20
class=3Dbr0>}</SPAN><SPAN class=3Dbr0>)</SPAN>;</DIV>
<P>Running this code, you will see an error appear, but it's nowhere =
near the=20
right location:</P><A title=3D"View: debugging8.png"=20
href=3D"http://www.dojotoolkit.org/files/debugging8.png"><IMG =
class=3Dinline=20
title=3Ddebugging8.png alt=3Ddebugging8.png=20
src=3D"http://www.dojotoolkit.org/files/debugging8.png"></A>=20
<P>But by simply setting the debugAtAllCosts flag to true:</P>
<DIV class=3Dgeshifilter style=3D"FONT-FAMILY: monospace"><SPAN =
class=3Dsc2><A=20
href=3D"http://december.com/html/4/element/script.html"><SPAN=20
class=3Dkw2><script</SPAN></A> <SPAN class=3Dkw3>type</SPAN>=3D<SPAN=20
class=3Dst0>"text/javascript"</SPAN> <SPAN =
class=3Dkw3>src</SPAN>=3D<SPAN=20
class=3Dst0>"/dojoroot/dojo/dojo.js"</SPAN> <BR> =
=20
djConfig=3D<SPAN class=3Dst0>"parseOnLoad: true, debugAtAllCosts: =
true"</SPAN><SPAN class=3Dkw2>></SPAN></SPAN><SPAN class=3Dsc2><SPAN=20
class=3Dkw2></script></SPAN></SPAN></DIV>
<P>the displayed error location will now be correct:</P><A=20
title=3D"View: debugging7.png"=20
href=3D"http://www.dojotoolkit.org/files/debugging7.png"><IMG =
class=3Dinline=20
title=3Ddebugging7.png alt=3Ddebugging7.png=20
src=3D"http://www.dojotoolkit.org/files/debugging7.png"></A>=20
<P><B>Important!</B> you should always remove debugAtAllCosts from =
production=20
code. It slows down the client unnecessarily. Rather than manually =
inserting and=20
removing them, I like to delegate that job to a server side language =
like=20
PHP:</P>
<DIV class=3Dgeshifilter style=3D"FONT-FAMILY: monospace"><SPAN=20
class=3Dkw2><?php</SPAN><BR><SPAN class=3Dre0>$djConfig</SPAN> =
=20
=3D <SPAN class=3Dre0>$inProduction</SPAN> ? <SPAN =
class=3Dst0>"parseOnLoad:=20
true"</SPAN> : <SPAN class=3Dst0>"parseOnLoad: true, debugAtAllCosts:=20
true"</SPAN>;<BR><SPAN class=3Dre0>$loadLocation</SPAN> =3D <SPAN=20
class=3Dre0>$inProduction</SPAN> ? <SPAN=20
class=3Dst0>"http://o.aolcdn.com/dojo/1.0.0"</SPAN> : <SPAN=20
class=3Dst0>"/dojoroot"</SPAN>;<BR><SPAN class=3Dre0>$useXd</SPAN> =
=20
=3D <SPAN class=3Dre0>$inProduction</SPAN> ? <SPAN=20
class=3Dst0>".xd"</SPAN> : <SPAN class=3Dst0>""</SPAN>;<BR><SPAN=20
class=3Dkw2>?></SPAN><BR class=3Dgeshibr> <style =
type=3D<SPAN=20
class=3Dst0>"text/css"</SPAN>><BR> @import =
<SPAN=20
class=3Dst0>"<?=3D $loadLocation=20
?>/dijit/themes/tundra/tundra.css"</SPAN>;<BR> =
=20
@import <SPAN class=3Dst0>"<?=3D $loadLocation=20
?>/dojo/resources/dojo.css"</SPAN><BR> =
</style><BR> =20
<script type=3D<SPAN class=3Dst0>"text/javascript"</SPAN> =
src=3D<SPAN=20
class=3Dst0>"<?=3D $loadLocation ?>/dojo/dojo<?=3D $useXd =
?>.js"</SPAN>=20
<BR> djConfig=3D<SPAN =
class=3Dst0>"<?=3D=20
$djConfig ?>"</SPAN>></script></DIV>
<DIV class=3Dbook-navigation>
<DIV class=3D"page-links clear-block"><A class=3Dpage-previous=20
title=3D"Go to previous page"=20
href=3D"http://dojotoolkit.org/book/dojo-book-0-9/hello-world-tutorial">=E2=
=80=B9 Hello=20
World - Dojo for the Attention-Impaired</A><A class=3Dpage-up=20
title=3D"Go to parent page"=20
href=3D"http://dojotoolkit.org/book/dojo-book-0-9-0">up</A><A =
class=3Dpage-next=20
title=3D"Go to next page"=20
href=3D"http://dojotoolkit.org/book/dojo-book-0-9/introduction">Introduct=
ion=20
=E2=80=BA</A></DIV></DIV></DIV>
<DIV class=3Dlinks>
<UL class=3D"links inline">
<LI class=3D"first book_printer"><A class=3Dbook_printer=20
title=3D"Show a printer-friendly version of this book page and its =
sub-pages."=20
href=3D"http://dojotoolkit.org/book/export/html/4549">Printer-friendly =
version</A>=20
<LI class=3Dcomment_forbidden><SPAN class=3Dcomment_forbidden><A=20
=
href=3D"http://dojotoolkit.org/user/login?destination=3Dnode/4549%2523com=
ment-form">Login</A>=20
or <A=20
=
href=3D"http://dojotoolkit.org/user/register?destination=3Dnode/4549%2523=
comment-form">register</A>=20
to post comments</SPAN>=20
<LI class=3D"last subscriptions_add_node"><A =
class=3Dsubscriptions_add_node=20
title=3D"Receive an e-mail whenever a comment is posted to this Book =
page."=20
href=3D"http://dojotoolkit.org/subscriptions/add/node/4549">Subscribe =
post</A>=20
</LI></UL></DIV></DIV>
<DIV id=3Dcomments><A id=3Dcomment-9407></A>
<DIV class=3Dcomment>
<H3 class=3Dtitle><A class=3Dactive=20
href=3D"http://dojotoolkit.org/book/book-dojo/part-4-meta-dojo-making-you=
r-dojo-code-run-faster-and-better/debugging-facilities/deb#comment-9407">=
how=20
to not showing the log?</A></H3>
<DIV class=3Dsubmitted>Submitted by vanholy on Tue, 11/27/2007 - =
11:28.</DIV>
<DIV class=3Dcontent>
<P>In the final version of my application there is a command as log4j =
config=20
file to not show the<BR>"<I>console.log("Nothing happening"); =
</I>"<BR>messages=20
in console?</P></DIV>
<DIV class=3Dlinks>
<UL class=3Dlinks>
<LI class=3D"first last comment_forbidden"><SPAN =
class=3Dcomment_forbidden><A=20
=
href=3D"http://dojotoolkit.org/user/login?destination=3Dnode/4549%2523com=
ment-form">Login</A>=20
or <A=20
=
href=3D"http://dojotoolkit.org/user/register?destination=3Dnode/4549%2523=
comment-form">register</A>=20
to post comments</SPAN> </LI></UL></DIV></DIV>
<DIV class=3Dindented><A id=3Dcomment-9411></A>
<DIV class=3Dcomment>
<H3 class=3Dtitle><A class=3Dactive=20
href=3D"http://dojotoolkit.org/book/book-dojo/part-4-meta-dojo-making-you=
r-dojo-code-run-faster-and-better/debugging-facilities/deb#comment-9411">=
Interestingly=20
no...</A></H3>
<DIV class=3Dsubmitted>Submitted by criecke on Tue, 11/27/2007 - =
13:10.</DIV>
<DIV class=3Dcontent>
<P>Firebug doesn't have that feature ... I suppose because the browser =
itself=20
controls what level messages are printed. I assume you're asking for =
performance=20
reasons? I wouldn't mind doing some performance tests unless someone has =
done it=20
already.</P></DIV>
<DIV class=3Dlinks>
<UL class=3Dlinks>
<LI class=3D"first last comment_forbidden"><SPAN =
class=3Dcomment_forbidden><A=20
=
href=3D"http://dojotoolkit.org/user/login?destination=3Dnode/4549%2523com=
ment-form">Login</A>=20
or <A=20
=
href=3D"http://dojotoolkit.org/user/register?destination=3Dnode/4549%2523=
comment-form">register</A>=20
to post comments</SPAN> </LI></UL></DIV></DIV></DIV></DIV><!-- =
/main_content region --></DIV></DIV>
<DIV class=3D"col-c content-region-container">
<DIV id=3Dsidebar-right-container></DIV></DIV><BR class=3Dclear></DIV>
<DIV class=3Dcols-a50b50 id=3Dafter-content-block>
<DIV class=3D"col-a content-region-container" =
id=3Dafter-content-block-1></DIV>
<DIV class=3D"col-b content-region-container" =
id=3Dafter-content-block-2><BR=20
class=3Dclear></DIV><BR class=3Dclear></DIV><BR clear=3Dall></DIV>
<DIV class=3Dcontent-region-container>
<DIV id=3Dnavigation-block>
<DIV id=3Dbreadcrumb-block>
<DIV id=3Dbreadcrumbs>
<DIV class=3Dbreadcrumb><A href=3D"http://dojotoolkit.org/">Home</A> =
=C2=BB <A=20
href=3D"http://dojotoolkit.org/book/dojo-book-0-9-0">The Book of =
Dojo</A> =C2=BB=20
Debugging Tutorial</DIV></DIV></DIV>
<DIV class=3Dcols-abcd id=3Dmain-menu-block><!-- Block: menu -->
<DIV class=3D"block block-menu" id=3Dblock-menu-573>
<DIV class=3Dcontent>
<UL class=3Dmenu>
<LI class=3Dleaf id=3Dmenu-item-574><A title=3D"See the Dojo Toolkit =
in action!"=20
href=3D"http://dojotoolkit.org/demos">Demos</A>=20
<LI class=3Dexpanded id=3Dmenu-item-575><A=20
title=3D"Get started with the Dojo Toolkit, fast"=20
href=3D"http://dojotoolkit.org/docs/quickstart">Quick Start</A>=20
<UL class=3Dmenu>
<LI class=3Dleaf id=3Dmenu-item-576><A title=3D"Get the toolkit"=20
href=3D"http://dojotoolkit.org/downloads">Downloads</A>=20
<LI class=3Dleaf id=3Dmenu-item-577><A title=3D"See examples of the =
Dojo Toolkit"=20
href=3D"http://dojotoolkit.org/demos">Examples</A>=20
<LI class=3Dleaf id=3Dmenu-item-639><A=20
href=3D"http://dojotoolkit.org/spotlight">Spotlight</A> </LI></UL>
<LI class=3Dexpanded id=3Dmenu-item-578><A=20
href=3D"http://dojotoolkit.org/about">About</A>=20
<UL class=3Dmenu>
<LI class=3Dleaf id=3Dmenu-item-579><A=20
href=3D"http://dojotoolkit.org/about">Overview</A>=20
<LI class=3Dleaf id=3Dmenu-item-580><A=20
href=3D"http://dojotoolkit.org/about/features">Features</A>=20
<LI class=3Dleaf id=3Dmenu-item-581><A=20
href=3D"http://dojotoolkit.org/about/press">Press</A>=20
<LI class=3Dleaf id=3Dmenu-item-582><A=20
href=3D"http://dojotoolkit.org/about/contact">Contact</A>=20
</LI></UL></LI></UL></DIV></DIV><!-- Block: menu -->
<DIV class=3D"block block-menu" id=3Dblock-menu-589>
<DIV class=3Dcontent>
<UL class=3Dmenu>
<LI class=3Dexpanded id=3Dmenu-item-583><A=20
href=3D"http://dojotoolkit.org/downloads">Downloads</A>=20
<UL class=3Dmenu>
<LI class=3Dleaf id=3Dmenu-item-584><A=20
href=3D"http://dojotoolkit.org/downloads">Current releases</A>=20
<LI class=3Dleaf id=3Dmenu-item-585><A=20
href=3D"http://archive.dojotoolkit.org/nightly/">Nightly builds</A>=20
<LI class=3Dleaf id=3Dmenu-item-586><A=20
href=3D"http://archive.dojotoolkit.org/">Archives</A>=20
<LI class=3Dleaf id=3Dmenu-item-587><A=20
href=3D"http://trac.dojotoolkit.org/roadmap?show=3Dall">Change =
logs</A>=20
<LI class=3Dleaf id=3Dmenu-item-588><A=20
href=3D"http://dojotoolkit.org/downloads/releasenotes">Release =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -