Uncaught-TypeError-Cannot-call-method-substring-of-undefined-sencha-touch-all.js
我是Sencha Touch的新手,尽管我对MVC知之甚少,但是在尝试按照Sencha Touch 2的视频教程来构建应用程序时遇到错误,如下所示:
Uncaught TypeError: Cannot call method 'substring' of undefined
sencha-touch-all.js:35
代码如下:
app.js:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 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-视图
1 2 3 4 5 6 7 8 9 | Ext.define('SBR.view.Home', { extend: 'Ext.Panel', xtype: 'homepanel', config:{ title: 'Home', iconCls: 'home', html: 'Html through View' } }); |
Main.js-控制器
1 2 3 4 5 6 7 | Ext.define('SBR.controller.Main',{ extend: 'Ext.app.Controller', views: ['Home'], init: function(){ console.log('It is tested - Ok'); } }); |
如果在app.js中设置视图(Home.js)的代码而不使用xtype,则可以正常工作,但是当我定义视图并尝试通过app.js中的xtype访问视图时,它确实可以虽然无法正常工作并引发以上异常,但它会在控制台中成功记录了在控制器中传递的消息。
使用的浏览器:Chrome
IDE:Aptana
Sencha Touch版本:2.0
您需要以与添加控制器相同的方式在app.js中添加所有View,Store和Model类:
1 2 3 4 5 6 | controllers: [ 'Main' ], views : [ 'Home' ] |
这应该使它起作用。