Sencha Touch Guide
1.一些命令
创建APP
# Make sure the current working directory is the Sencha Touch 2 SDK 例如D:\Program Files\wamp\www\sencha-touch-2.1.1-commercial
cd /path/to/sencha-touch-2-sdk sencha generate app MyApp /path/to/www/myapp
生成模型MODEL
cd /path/to/www/myapp sencha generate model User id:int,name,email
更新
cd /path/to/www/myapp sencha app upgrade /path/to/new_version_of_sdk
2.Demo实例
根据官方的指导手册,使用Sencha Cmd我们可以快速的创建一个App.
我们首先预览一下改进的界面:

Pic-1 首页

pic-2 音乐

pic-3 视频

pic-4 blog

pic-5 联系我们
1)修改 MyApp\app\view目录下的MainView.js 文件
Ext.define('MyApp.view.Main', {
extend: 'Ext.tab.Panel',
xtype: 'main',
requires: [
'Ext.TitleBar',
'Ext.Video',
'Ext.dataview.NestedList',
'Ext.data.proxy.JsonP',
'Ext.form.Panel',
'Ext.Audio',
'Ext.form.FieldSet',
'Ext.field.Email'
],
config: {
xtype: 'tabpanel',
fullscreen: true,
tabBarPosition: 'bottom',
items: [
{
title: '首页',
iconCls: 'home',
scrollable: true,
cls: 'home',
html: [
'<p> </p>',
'<img height=260 src="resources/icons/yu.png" />',
'<h1>欢迎来到【鱼的记忆】</h1>',
'<p>Hi, I\'m Tony, Welcome to my blog, may you will like it.',
'<br/>[1]联系方式: leegtang@126.com</p>',
'<h2>--鱼的记忆</h2>'
].join("")
},
{
title: '音乐',
iconCls: 'volume',
displayField: 'title',
xtype: 'audio',
url : 'resources/audio/adq.mp3'
},
{
title: '视频',
iconCls: 'video',
xtype : 'video',
x : 600,
y : 300,
width : 428,
height : 320,
url : "resources/audio/dby.mp4",
posterUrl: 'resources/audio/dby.png'
},
{
xtype: 'nestedlist',
title: '博客',
iconCls: 'star',
displayField: 'title',
store: {
type: 'tree',
fields: [
'title', 'link', 'author', 'contentSnippet', 'content',
{name: 'leaf', defaultValue: true}
],
root: {
leaf: false
},
proxy: {
type: 'jsonp',
url: 'blog.php',
//url: 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.feedburner.com/SenchaBlog',
reader: {
type: 'json',
rootProperty: 'responseData.feed.entries'
}
}
},
detailCard: {
xtype: 'panel',
scrollable: true,
styleHtmlContent: true
},
listeners: {
itemtap: function(nestedList, list, index, element, post) {
this.getDetailCard().setHtml(post.get('content'));
}
}
},
{
title: '联系我们',
iconCls: 'user',
xtype: 'formpanel',
url: 'contact.php',
layout: 'vbox',
items: [
{
xtype: 'fieldset',
title: '联系我们',
instructions: '(<font color="red">*</font>为必填项)',
height: 285,
items: [
{
xtype: 'textfield',
label: '姓名<font color="red">*</font>',
name: 'name'
},
{
xtype: 'emailfield',
label: 'Email<font color="red">*</font>',
name: 'email'
},
{
xtype: 'textareafield',
label: '内容<font color="red">*</font>',
name: 'message',
height: 90
}
]
},
{
xtype: 'button',
text: '提交',
ui: 'confirm',
// The handler is called when the button is tapped
handler: function() {
// This looks up the items stack above, getting a reference to the first form it see
var form = this.up('formpanel');
// Sends an AJAX request with the form data to the url specified above (contact.php).
// The success callback is called if we get a non-error response from the server
form.submit({
waitMsg: '正在提交...',
success: function() {
// The callback function is run when the user taps the 'ok' button
Ext.Msg.alert('非常感谢', '您的内容已经提交,我们会尽快联系你。', function() {
form.reset();
});
},
failure: function(form,action){
Ext.Msg.alert('内容提交失败', action.errormsg);
}
});
}
}
]
}
]
}
});
2)修改MyApp\resources\css目录下的 app.css,增加一下内容
.home {
text-align: center;
}
.home h1 {
font-weight: bold;
font-size: 1.2em
}
.home p {
color: #666;
font-size: 0.8em;
line-height: 1.6em;
margin: 10px 20px 20px 20px
}
.home img {
margin-top: -10px
}
.home h2 {
color: #999;
font-size: 0.7em
}
.blog p {
color: #555;
padding: 20px 20px 0 20px;
font-size: 1em;
line-height: 1.4em
}
.x-tab .x-button-icon.volume:before,.x-button .x-button-icon.volume:before {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
text-align: center;
font-family: "Pictos";
content: "B";
}
.x-tab .x-button-icon.video:before,.x-button .x-button-icon.video:before {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
text-align: center;
font-family: "Pictos";
content: "V";
}
3)增加MainView.js中涉及的资源文件
4)添加blog.php
<?php
/**
* Blog feed data
*
*/
/**
* {
responseData: {
feed: {
entries: [
{author: 'Bob', title: 'Great Post', content: 'Really good content...'}
]
}
}
}
*/ /**
* http://localhost/MyApp/blog.php?_dc=1396706826288&node=ext-data-treestore-1-root&page=1&start=0&limit=25&callback=Ext.data.JsonP.callback1
*/
header("Content-type:application/json;charset=utf8;");
$jsonp=$_GET['callback'].'({"responseData":{"feed":{"entries":['; for($i=1;$i<21;$i++){
$author=json_encode('leegtang');
$title=json_encode('今天的博文标题'.$i);
$content=json_encode('博文'.$i.'内容');
$contentSnippet=json_encode('博文'.$i.'内容简介');
$link='blogv.php?id='.$i;
$jsonp.='{"author":'.$author.',"title":'.$title.',"content":'.$content.',"link":"'.$link.'","contentSnippet":'.$contentSnippet.'}';
if($i!=20)$jsonp.=',';
} $jsonp.=']}},"responseStatus": 200});';
echo $jsonp;
?>
5)增加contact.php
<?php $flag='false';
$msg='';
if($_POST['name'] == ''){
$msg='请填写姓名';
}else if( $_POST['email'] == '' ){
$msg='请填写Email';
}else if($_POST['message'] == ''){
$msg='请填写内容';
}else{
// 保存反馈信息
// ....
$flag='true'; } echo '{"success":'.$flag.',"errormsg":"'.$msg.'"}';
?>
好了,项目完成。
Sencha Touch Guide的更多相关文章
- sencha touch打包成安装程序
为了更好地向大家演示如何打包一个sencha touch的项目,我们用sencha cmd创建一个演示项目,如果你的sencha cmd环境还没有配置,请参照 sencha touch 入门系列 (二 ...
- 跟我一起玩转Sencha Touch 移动 WebApp 开发(一)
1.目录 移动框架简介,为什么选择Sencha Touch? 环境搭建 创建项目框架,框架文件简介 创建简单Tabpanel案例 自定义图标的方式 WebApp产品测试和发布 HTML5离线缓存 发布 ...
- sencha touch
download http://www.sencha.com/products/touch/thank-you/ Developer Center http://developer.sencha.co ...
- sencha touch 2.3 结合cordova 环境搭建
sencha touch 2.3环境搭建必备工具 sencha touch 2.3 包sencha cmd 4.0以上JAVA JDK 1.7以上(注意JDK和JRE的区别)Ruby 1.9.3或更早 ...
- 【翻译】探究Ext JS 5和Sencha Touch的布局系统
原文:Exploring the Layout System in Ext JS 5 and Sencha Touch 布局系统是Sencha框架中最强大和最有特色的一个部分. 布局要处理应用程序中每 ...
- 跟我一起玩转Sencha Touch 移动 WebApp 开发1
跟我一起玩转Sencha Touch 移动 WebApp 开发(一) 1.目录 移动框架简介,为什么选择Sencha Touch? 环境搭建 创建项目框架,框架文件简介 创建简单Tabpanel案例 ...
- Sencha touch API
Sencha touch API http://docs.sencha.com/touch/2.3.1/#!/guide/getting_started
- 第二步 (仅供参考) sencha touch 使用cmd打包apk
最新版本的cmd可以直接将sencha touch项目打包成本地应用,不过还有很多不足,本文仅供参考 通过sencha app build native命令可以直接将项目打包成本地应用,不过在命令运行 ...
- sencha touch 扩展篇之将sencha touch打包成安装程序(上)- 使用sencha cmd打包安装程序
由于最近一直忙着android原生的开发,很久没有更新博客了,官方的sencha cmd工具功能非常强大,创建项目,压缩项目,打包安装程序都能轻松实现,这讲我们就给大家介绍下如何使用sencha cm ...
随机推荐
- iOS 使用fir、 蒲公英 进行内部测试
fir 蒲公英需要去注册账号并认证,按提示即可完成. 测了公司账号.个人开发账号,2个都可以用,就是要在配置文件里加上测试者的udid. 步骤: 1.添加测试机的udid edit配置文件,添加刚刚加 ...
- LINUX 系统备份
系统备份是系统管理工作中十分重要的一个环切,本文详细介绍了各种Linux系统的备份方法,相信对大家的日常管理工作有所帮助. 备份是一项重要的工作,但是很多人没有去做.一旦由于使用不当造成数据丢失,备份 ...
- 关于NSRunLoop和NSTimer的深入理解
一.什么是NSRunLoop NSRunLoop是消息机制的处理模式 NSRunLoop的作用在于有事情做的时候使的当前NSRunLoop的线程工作,没有事情做让当前NSRunLoop的线程休眠 NS ...
- Java基础知识强化之IO流笔记37:FileReader/FileWriter(转换流的子类)复制文本文件案例
1. 转换流的简化写法: 由于我们常见的操作都是使用本地默认编码,所以,不用指定编码.而转换流的名称有点长,所以,Java就提供了其子类供我们使用:FileReader / FileWriterOut ...
- c指针与数组,传参问题,指针数组与数组指针的区别,二维数组动态内存分配
一 数组的结构:顺序存储,看谭浩强中的图,牢记 1.数组名指代一种数据结构:数组 现在可以解释为什么第1个程序第6行的输出为10的问题,根据结论1,数组名str的内涵为一种数据结构,即一个长度为10的 ...
- 远程之SSH
SSH(Secure Shell的缩写),由 IETF 的网络工作小组(Network Working Group)所制定:SSH 为建立在应用层和传输层基础上的安全协议.SSH 是目前较可靠,专为远 ...
- git研究1
error:src refspec master does not match any 将本地GIT版本库PUSH到一个GITHUB上一个空的版本库时出现错误,本地版本库为空, 空目录不能提交 (只 ...
- C#微信公众号开发 -- (三)用户关注之后自动回复
通过了上一篇文章之后的微信开发者验证之后,我们就可以做微信公众号的代码开发了. 当我们点击关注某个公众号的时候,有时候会发现他会自动给我们回复一条消息,比如欢迎关注XXX公众号.这个功能其实是在点击关 ...
- 利用SQL语句给字段加注释
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色Id',--注释名称 @level0type=N'SCHEMA' ...
- node.js 访问sql server的 node_modules “msnodesql"的安装编译方法
http://stackoverflow.com/questions/19661811/unable-to-download-msnodesql-0-2-1-v0-10-x64-msi 首先要满足以下 ...