【发布时间】:2013-05-02 15:07:20
【问题描述】:
我是 Sencha Touch 的新手,虽然我对 MVC 知之甚少,但在尝试按照 Sencha Touch 2 的视频教程构建应用程序时遇到错误:
未捕获的类型错误:无法调用未定义的方法“子字符串” sencha-touch-all.js:35
代码如下:
app.js:
Ext.Loader.setConfig({
enabled: true
});
Ext.application({
name: 'SBR',
controllers: [
'Main'
],
launch: function(){
Ext.create('Ext.TabPanel',{
fullscreen: true,
tabBarPosition: 'bottom',
items: [
{
xtype: 'homepanel'
},
{
xtype: 'carousel',
title: 'Blog',
iconCls: 'star',
html: 'Student Blog',
items: [
{
xtype: 'image',
src: 'resources/images/icon1.png'
},
{
xtype: 'image',
src: 'resources/images/icon2.png'
}]
},
{
title: 'Enter your Comments',
iconCls: 'star',
html: 'Enter your Comments'
}
]
});
}
});
Home.js - 视图
Ext.define('SBR.view.Home', {
extend: 'Ext.Panel',
xtype: 'homepanel',
config:{
title: 'Home',
iconCls: 'home',
html: 'Html through View'
}
});
Main.js - 控制器
Ext.define('SBR.controller.Main',{
extend: 'Ext.app.Controller',
views: ['Home'],
init: function(){
console.log('It is tested - Ok');
}
});
如果视图的代码 (Home.js) 在 app.js 中设置而不使用 xtype,它可以正常工作,但是当我定义视图并尝试从 app.js 通过 xtype 访问视图时它会不起作用并抛出上述异常,尽管它在控制台中记录了控制器中成功传递的消息。
使用的浏览器:Chrome
IDE:Aptana
煎茶触控版本:2.0
【问题讨论】:
标签: model-view-controller extjs sencha-touch