Alloy(合金)是Appcelerator公司为Titanium开发的一个新的框架,采用MVC结构,内部代码编号“ZipTi”。从整体上看更类似于Ruby on Rails(代码构成,命令行操作等)。
源码依旧托管在GitHub:
https://github.com/appcelerator/alloy
【局限性】
(1)只能应用于OSX
(2)目前的状态是Unstable
【目的】
(1)提高开发效率Productivity
(2)提高可维护性Maintainability
(3)确保最佳实战Best Practices
【安装】
Alloy采用npm发布(前提是需要Node.JS NPM的环境)通过下面的命令来安装:
引用
[sudo] npm install -g alloy
也可以先克隆到本地,然后再安装
引用
git clone https://github.com/appcelerator/alloy.git
引用
[sudo] npm install -g .
【创建app】
先通过Titanium Studio,titanium.py,Titanium CLI创建一个项目,然后在控制台,进入项目的根目录输入以下命令:
引用
alloy new .
.__ .__
_____ | | | | ____ ___.__.
\__ \ | | | | / _ < | |
/ __ \| |_| |_( <_> )___ |
(____ /____/____/\____// ____|
\/ \/
Alloy by Appcelerator. The MVC app framework for Titanium.
2012-07-18 13:44:20 -- [DEBUG] Creating directory: plugins
2012-07-18 13:44:20 -- [DEBUG] Creating directory: plugins/ti.alloy
2012-07-18 13:44:20 -- [INFO ] Deployed ti.alloy plugin to plugins/ti.alloy/plugin.py
2012-07-18 13:44:20 -- [INFO ] Installed 'ti.alloy' plugin to tiapp.xml
2012-07-18 13:44:20 -- [INFO ] Generated new project at: app
创建成功后,就会作成一个叫app的文件夹,其中包含了alloy app的骨架代码。
【目录构成】
- views - this is where your views should go in the format view.xml
- controllers - this is where your controllers should go in the format view.js.
- styles - this is where your view styling logic should go in the format view.json.
- models - this is where your model files will go.
- assets - this is where you should put your image assets and other misc. files that you want copied into the Resources directory.
- migrations - this is where your database migration files will be stored.
- lib - this is where you should put application specific files, typically in the CommonJS format.
- vendor - this is where you should put any vendor specific modules, typically in the CommonJS format. Do not place native modules in this folder.
- config - Contains application specific config.
主要的几个文件:
(1)app/controllers/index.js
Controller :主要是事件处理,业务逻辑
$.t.on('click',function(e) {
alert($.t.text);
});
$.index.open();
- $ ----Alloy包装对象别名
- $.t ---获取ID为"t"的对象
- on("事件名", "回调函数") ---等价于addEventListener函数
(2)app/styles/index.json
Style:类似于CSS,设置UI的颜色,大小等
{
".container": {
"backgroundColor":"white"
},
"Label": {
"width": Ti.UI.SIZE,
"height": Ti.UI.SIZE,
"color": "#000"
}
}
(3)app/views/index.xml
View:类似于HTML,设置UI布局
<Window class="container">
<Label id="t">Hello, World</Label>
<Button id="b">Click me</Button>
</Window>
采用XML定义页面UI控件以及从属关系
Window = Ti.UI.Window
Label = Ti.UI.Label
XML中定义的属性就是控件的初始参数值。
如果使用Ti.UI以外的View,比如MapView的话,使用一下方法:
<View ns="Ti.Map" id="map">
【开发】
可以通过Titanium Studio来开发,也可以使用控制台。
(1)Titanium Studio的话,通过plugins/ti.alloy来运行
(2)CLI的话
通过以下命令运行
引用
alloy compile
alloy run . iphone (目前只支持iphone)
通过命令行生成代码:
引用
alloy generate view <name>
alloy generate controller <name>
alloy generate model <name> [column_name:type, ...]
alloy generate migration <name>
alloy generate widget <name>
详细可以参考
https://github.com/appcelerator/alloy
官方发布的MVC框架,构成上是否合理也有待于广大Ti开发者的验证。不过如果布局采用XML定义的话,那么可视化开发工具将不会太遥远了!。
- 大小: 14.1 KB
分享到:
相关推荐
合金冶炼厂Appcelerator Titanium MVC 框架合金项目应用程序的辅助命令。为什么是合金冶炼厂? 我经常移动、重命名和删除控制器。安装$ [sudo] npm install -g alloy-smelter 安装边缘版本。 [sudo] npm install -g ...
ChariTi是一个非常不错的Titanium MVC框架。此框架的特点是很多东西可直接通过配置文件实现,如APP的主题颜色,每个tab的内容,是否使用滑动菜单布局,是否支持tablet布局等,而且其对iOS 和 android也有很好的支持...
ASTM B861 ASME SB 861-2010 Titanium and Titanium Alloy
Alloy是用于的MVC应用程序框架。 可以在以下位置找到更多高级详细信息: : 入门 涵盖了从安装到使用Alloy创建第一个应用程序的所有内容。 完整集合 在实践中显示合金各个方面。 安装 来自npm: # install the ...
napp.alloy.adapter.restapi, 用于 Titanium 合金框架的RestAPI同步适配器 napp.alloy. adapter.restapi用于 Titanium 合金框架的RestAPI同步适配器。响应代码适配器的设计具有以下结构。200: 请求成功。201: 已经...
sublimetext-tita, Tita Titanium Mobile/Alloy sublime text 2插件 这个插件不再主动地维护 ***因为我不再使用 st2/st3 。 有人对 fork 感兴趣并维护它?替代插件:...
Appcelerator Titanium 3.4+ Alloy 1.5+ 设备端应用。 ###Setup insctructions 除了 npm 依赖,这个项目还依赖共享 JS 代码库项目,在这个项目的 app/lib/core 目录中进行链接。 因此,设置此项目需要以下内容: ...
atom-titanium, 用于 Titanium 合金的Atom 封装 用于 Titanium 合金的 All-in-One封装这是一个用于 Titanium 合金的Atom 封装。$ apm install titanium-alloy冲突&需要通知Alloy 1.8. x
该项目包装了 Parse javascript 和 REST API,用于 Appcelerator Titanium 和 Alloy 项目。 安装 将 ti-parse.js 和解析库复制到您的 lib 目录。 将 src/lib/alloy/sync/parse.js 中的同步适配器复制到 app/lib/...
它旨在与当今的 Web 数据库(例如 MongoDB)和流行的 MVC 框架(例如 AngularJS)轻松集成。 我们已经发布了适用于移动和 PC 浏览器的 Javascript 实现,我们正在开发适用于 iOS 和 Android 的原生版本,这些版本将...
[Packt Publishing] Appcelerator Titanium 移动应用开发教程 (英文版) [Packt Publishing] Creating Mobile Apps with Appcelerator Titanium (E-Book) ☆ 图书概要:☆ Develop fully-featured mobile ...
Titanium中文版开发手册(翻译版)
Titanium Backup_3.7.4捐赠完全版
TitaniumBackup_6.0.5.1 专业版 可静默恢复
一个免费开源的应用程序开发平台,使用你熟悉的javascript, HTML, CSS, Python,Ruby和PHP等web开发技能创建mobile,tablet和desktop的原生应用程序 一个免费开源的应用程序开发平台,使用你熟悉的javascript, HTML, ...
Building Mobile Applications with Titanium, 这是mobi版,适合knidle等电子书阅读。 详细介绍了titanium框架的使用
titanium-d1-kickstart.6.1.1.gbin 强大的思科模拟器
支持的钛合金版本用法要安装到 haxelib,请运行haxelib git titanium_mobile_externs https://github.com/momer/haxe_titanium_mobile.git <version> haxelib 截至本次更新,最新为 1.5.1-rc1。 使用 externs 很简单...
第一次使用钛备份的朋友,可以试着自定义一下文件备份的路径:钛备份默认会将程序和数据备份在SD卡的 TitaniumBackup文件夹里,但如果是像白鸽这样使用的包含内置和外置两种SD 卡的手机Atrix 4G的话(这样的手机除 ...