假设我们的工程目录如下:
<pre class="brush:php;toolbar:false;"> -- HelloWorld.html<br><br> |-- js/<br><br> -- dojo/ /*此处是dojo包下面的文件,列表如下<BR><pre class="brush:php;toolbar:false;"> -- build.txt<BR> -- CHANGELOG<BR> -- demos<br><br> -- ..<BR> -- dojo.js<BR> -- dojo.js.uncompressed.js<BR> -- iframe_history.html<BR> -- LICENSE<BR> -- README<BR> -- src/<br><br>
<pre class="brush:php;toolbar:false;"><html><BR> <head><BR> <title>Dojo: Hello World!</title><br><br> <!-- SECTION 1 --><BR> <script type="text/javascript" src="js/dojo/dojo.js"></script><br><br> <!-- SECTION 2 --> <BR> </head><br><br> <body><BR> </body><BR></html>
<pre class="brush:php;toolbar:false;"><button dojoType="Button" widgetId="helloButton">Hello World!</button><br><br>上面不一定要使用widgetId,用平常的id就行了,widget会自己将其转化为widgetId。<BR>
<pre class="brush:php;toolbar:false;"> <!-- SECTION 2 --><BR> <script type="text/javascript"><br><br> //引入库<BR> //event.*是处理事件,比如:点击,的所有包。<BR> dojo.require("dojo.event.*");<BR> dojo.require("dojo.widget.*");<BR> dojo.require("dojo.widget.Button");<br><br> //点击按钮后调用的函数<BR> function helloPressed()<BR> {<BR> alert('You pressed the button');<BR> }<br><br> //将helloButton的点击事件绑定到helloPressed()函数<BR> function init()<BR> {<BR> var helloButton = dojo.widget.byId('helloButton');//获得button对象<BR> dojo.event.connect(helloButton, 'onClick', 'helloPressed')//绑定,这只是其中一种绑定方法<BR> }<br><br> dojo.addOnLoad(init);//当然也可以将init函数命为其它的名<BR> </script><BR><pre class="brush:php;toolbar:false;">这样,就完成了HelloWorld.html的代码. 试试吧.<br><br>另外,要注意的是:<BR>如果init函数已经运行了,我们再使用<CODE>document.getElementById</CODE> 就没用了. 因为DOM<BR>已经被widget改变. 只能用dojo.widget.byId.<BR>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号