今天不是很忙,闲着无聊想玩玩Dojo,无奈找了一些资料没有详细介绍怎么搭建Dojo开发环境的。我自己来try一把把。
1 先安装个application server,选用apache。http://labs.renren.com/apache-mirror/tomcat/tomcat-6/v6.0.35/bin/
2 下载Dojo
http://download.dojotoolkit.org/release-1.2.4/
下载完成后在Apache的目录下建个文件夹,如js:
C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\js
3 解压文件到该文件夹
4 在浏览器中输入http://localhost:8080/js/dojo-release-1.2.4/dijit/themes/themeTester.html
可以看到如下:
如果在目录themes下面没有找到该html可以再http://download.dojotoolkit.org/release-1.2.4/dojo-release-1.2.4/dijit/themes/ 下载。
Dojo之hello world:
代码:
<html>
<head>
<title>test</title>
<script type="text/javascript"
src="dojo-release-1.2.4/dojo/dojo.js"
djConfig="parseOnLoad: true"></script>
<style type="text/css">
@import "dojo-release-1.2.4/dijit/themes/tundra/tundra.css";
</style>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.Button");
function init()
{
dojo.connect(dijit.byId("mybutton").domNode,"onclick","login");
}
function login()
{
if( dijit.byId("myname").value=="goodguy" &&
dijit.byId("mypassword").value=="goodgoodstudy")
alert("Dojo World welcome you!");
else
{
dijit.byId("myname").setValue("");
dijit.byId("mypassword").setValue("");
alert("Dojo does not like you!");
}
}
dojo.addOnLoad(init);
</script>
</head>
<body class="tundra">
UserName:
<input type="text" length="20" id="myname" dojoType="dijit.form.TextBox">
<br>
PassWord:
<input type="password" length="20" id="mypassword" dojoType="dijit.form.TextBox">
<br>
<div id="mybutton" dojotype="dijit.form.Button">Submit</div>
</body>
</html>
注意 代码不是我写的,来自http://www.ibm.com/developerworks/cn/web/wa-lo-dojointro1/‘
我只是进一步确保我的环境是OK的