Cha*_*ell 3 sencha-touch sencha-touch-2
我正在运行Sencha Touch V2 beta,我正在查看最新的文档.
我按照Ext.application说明操作,并尝试正确布置我的MVC应用程序.不幸的是,我无法弄清楚如何使用这种方法实际加载View.
index.js
Ext.application({
name: 'rpc',
defaultUrl: 'home/index',
controllers: ['home'], //note: define controllers here
launch: function () {
console.log('Ext.application ~ launch'),
Ext.create('Ext.TabPanel', {
id: 'rpc-rootPanel',
fullscreen: true,
tabBarPosition: 'bottom',
items: [{
title: 'Home',
iconCls: 'home'
}]
});
Ext.create('Ext.viewport.Viewport', {
id:'rpc-rootPanel',
fullscreen: true,
layout: 'card',
cardSwitchAnimation: 'slide'
});
}
});
Run Code Online (Sandbox Code Playgroud)
homeController.js
Ext.define('rpc.controller.home', {
extend: 'Ext.app.Controller',
views: ['home.index'],
stores: [],
refs: [],
init: function () {
console.log('rpc.controller.home ~ init');
},
index: function () {
console.log('rpc.controller.home ~ index');
}
});
Run Code Online (Sandbox Code Playgroud)
indexView.js
Ext.define('rpc.view.home.index', {
extend: 'Ext.Panel',
id: 'rpc-view-home-index',
config: {
fullscreen: true,
layout: 'vbox',
items: [{
xtype: 'button',
text: 'Videos',
handler: function () {
}
}],
html:'test'
}
});
Run Code Online (Sandbox Code Playgroud)
您可能提供的任何帮助将不胜感激.
新版本遵循ExtJS 4中引入的MVC概念.您应该阅读架构指南,因为Sencha Touch将遵循相同的arch.Here是我的文件夹结构:

在开发应用程序期间,您应该在html中使用sencha-touch-all-debug-w-comments.js.这有助于调试您的应用程序.
这是应用程序类:
Ext.Loader.setConfig({enabled: true});
Ext.application({
name: 'rpc',
appFolder: 'app',
controllers: ['Home'],
launch: function () {
Ext.create('Ext.tab.Panel',{
fullscreen: true,
tabBarPosition: 'bottom',
items:[{
title: 'Home',
iconCls: 'home',
html: '<img src="http://staging.sencha.com/img/sencha.png" />'
},{
title: 'Compose',
iconCls: 'compose',
xtype: 'homepage'
}]
});
}
});
Run Code Online (Sandbox Code Playgroud)
请注意,我如何使用别名(xtype:'homepage')包含主页视图.
这是控制器:
Ext.define('rpc.controller.Home', {
extend: 'Ext.app.Controller',
views: ['home.HomePage'],
init: function() {
console.log('Home controller init method...');
}
});
Run Code Online (Sandbox Code Playgroud)
最后,我的主页视图:
Ext.define('rpc.view.home.HomePage', {
extend: 'Ext.Panel',
alias: 'widget.homepage',
config: {
html: '<img src="http://staging.sencha.com/img/sencha.png" />'
},
initialize: function() {
console.log("InitComponent for homepage");
this.callParent();
}
});
Run Code Online (Sandbox Code Playgroud)
alias属性用于在需要时实例化类的实例.您也可以使用Ext.create方法.
我希望这可以帮助您开始使用Sencha Touch.
| 归档时间: |
|
| 查看次数: |
4091 次 |
| 最近记录: |