开始学习Sencha Touch
什么是Sencha Touch?
Sencha Touch 是一款高性能的html5框架. 你能使用 Sencha Touch 开发一款类似原生程序使用体验的webapp,然后通过移动网站或者加装混合外壳将其部署在移动设备上. Sencha Touch 支持 Android, iOS, Windows Phone, Microsoft Surface Pro and RT, 还有 BlackBerry 等设备.
软件环境
- Sencha Touch 必须使用 Chrome 或 Safari. 在移动设备上你能使用 Chrome, Safari, or Internet Explorer 10.
- Sencha Cmd.
- JDK 1.7 (1.6版本的JDK可以正常使用 但是推荐使用1.7版本). Sencha Cmd 是使用java编写的程序,必须JRE运行环境
- Ruby (版本1.9.3) 用于编译Sencha Touch的css文件. (2.0 版Ruby 不能再Sencha Cmd中正常使用)
- Windows: Download Ruby 1.9.3.n from rubyinstaller.org. Download the RubyInstaller .exe file and run it.
- Mac: Ruby is pre-installed. You can test which version you have with the ruby -v command. If you have version 2.0, download the Ruby version manager (rvm) and use this command to download and install Ruby: rvm install 1.9.3 --with-gcc=clang
Set your PATH variable to point to the Ruby 1.9.3 install directory. - Ubuntu: Use sudo apt-get install ruby1.9.3 to download and install Ruby 1.9.3.
- 最佳调试环境是使用Chrome 或者 Safari 这两款基于wekit内核的浏览器.
- To view Sencha Cmd options after installing Sencha Cmd, type sencha from the command line:
Windows: Press the Windows key + r and type cmd to get a Command Prompt.
Mac: Open a Terminal from Finder, Go, Utilities, Terminal.
Ubuntu: Click the Ubuntu Dashboard and type terminal in the search box.
- 创建一个项目目录用于放置应用程序,并确保目录可读写
Windows: Right-click the directory name, click Properties, and uncheck Read-only on the General tab.
Mac or Ubuntu: Use chmod o+w <dir_name> - 启动 sencha 自带的web服务并指定项目目录:
sencha fs web -port 8000 start -map <dir_name>
(你能使用任何未被使用的端口号.) 通过以下地址访问您的应用程序: http://localhost:8000/<目录名>/<应用程序名>
如果您使用iis作为web服务器, 请在IIS中为 Sencha Touch添加 application/x-json
这个 MIME类型. 如何添加MIME头请参考如下网站 http://stackoverflow.com/a/1121114/273985.