你好,游客 登录 注册 搜索
背景:
阅读新闻

在MyEclipse和Tomcat下配置Sencha Touch环境

[日期:2013-10-02] 来源:Linux社区  作者:Linux [字体:大 中 小]

首先要配置开发环境。这个很简单,只要到官方网站下载Sencha Touch压缩包即可http://www.sencha.com/products/touch/。

开发工具随便一个编辑器,记事本也可以的。

本人用的是MyEclipse+Tomcat,Sencha Touch用的是1.01版本(使用MyEclipse+Tomcat我为了以后例子可以跟后台交互)

其实可以直接浏览本地静态html文件的。

 

1,编写messageBox.html文件:

Html代码

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <metahttp-equiv="Content-Type"content="text/html; charset=utf-8">
  5. <title>messageBox.html</title>
  6. <linkrel="stylesheet"href="../../ext/resources/css/sencha-touch.css"type="text/css">
  7. <scripttype="text/javascript"src="../../ext/sencha-touch.js"></script>
  8. <scripttype="text/javascript"src="messageBox.js"></script>
  9. </head>
  10. <body>
  11. </body>
  12. </html>

如果你以前用过Extjs,那么这段代码你很容易明白。

  • 引入sencha-touch.css样式文件。
  • 引入sencha-touch.js核心库文件。
  • messageBox.js是例子用的文件。

2,编写messageBox.js文件:

Js代码

  1. Ext.setup({
  2. icon: '../icon.png',
  3. tabletStartupScreen: '../tablet_startup.png',
  4. phoneStartupScreen: '../phone_startup.png',
  5. glossOnIcon: false,
  6. onReady: function() {
  7. Ext.Msg.alert('提示', '第一个SenchaTouch程序!');
  8. }
  9. });

现在我们只关心onReady函数里面的代码,其他可以copy。

如果你以前做过Extjs那么看API难不到你。你可以在onReady中使用其他组件进行测试的。

3,运行效果:

本人使用的是Opera的手机模拟器(支持HTML5),google浏览器也可以的。

在浏览器输入http://localhost:8080/SenchaTouchTest/myExample/messageBox/messageBox.html

当然你可以直接打开html进行浏览而不必要部署到服务器(我为了以后例子可以跟后台交互)

Sencha Touch 的详细介绍:请点这里
Sencha Touch 的下载地址:请点这里

相关阅读:

Sencha Touch开发指南 http://www.linuxidc.com/Linux/2013-10/90852.htm

Sencha Touch的性能优化 http://www.linuxidc.com/Linux/2013-10/90854.htm

linux
相关资讯       Sencha Touch 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款