未捕获-类型错误,不能叩法 - 子 - 的 - 未定义 - 煎茶触摸-all.js [英] Uncaught-TypeError-Cannot-call-method-substring-of-undefined-sencha-touch-all.js

查看:127
本文介绍了未捕获-类型错误,不能叩法 - 子 - 的 - 未定义 - 煎茶触摸-all.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Sencha Touch的新手,虽然我对MVC的了解不多,但是当我尝试在Sencha Touch 2的视频教程之后构建一个应用程序时,我收到一个错误:


未捕获TypeError:无法调用未定义的方法'substring'
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: '学生博客',
项目:[
{
xtype:'image',
src:'resources / images / icon1.png'
},
{
xtype:'image',
src:'resources / images / icon2.png'
}]

},
{

标题:'输入你的C
iconCls:'star',
html:'输入您的评论'
}

]

});
}
});

Home.js - 视图

  Ext.define('SBR.view.Home',{
extends:'Ext.Panel',
xtype:'homepanel',
config: {
title:'Home',
iconCls:'home',
html:'Html through View'
}
});

Main.js - 控制器

  Ext.define('SBR.controller.Main',{
extends:'Ext.app.Controller',
views:['Home'],
init:function(){
console.log('它被测试 - Ok');
}
});

如果视图(Home.js)的代码在app.js中设置,而不使用xtype,它工作正常,但是当我定义一个视图并尝试从app.js访问xtype的视图时,它不起作用,并引发上述异常,尽管它在控制台中成功记录了控制器中传递的消息。 p>

浏览器已使用:Chrome



IDE:Aptana



Sencha Touch版本:2.0

解决方案

您需要以相同的方式在app.js中添加所有的View,Store和Model类你添加了控制器:

  controllers:[
'Main'
],
views :[
'Home'
]

这应该使它工作。 / p>

I am a new to Sencha Touch, though I have little knowledge about MVC, I am getting an error while I try to build an application following the video tutorial of Sencha Touch 2 as:

Uncaught TypeError: Cannot call method 'substring' of undefined sencha-touch-all.js:35

The code is as follows:

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 - the View

Ext.define('SBR.view.Home', {
    extend: 'Ext.Panel',
    xtype: 'homepanel',
    config:{
        title: 'Home',
        iconCls: 'home',
        html: 'Html through View'
    }
});

Main.js - The Controller

Ext.define('SBR.controller.Main',{
    extend: 'Ext.app.Controller',
    views: ['Home'],
    init: function(){
        console.log('It is tested - Ok');
    }
});

If the code of the view (Home.js) is set in the app.js without using a xtype, it works fine, but when I define a view and try to access the view by xtype from app.js it does not work and throws the above exception, although it logs the message passed in the controller successfully in the console.

Browser Used : Chrome

IDE : Aptana

Sencha Touch Version: 2.0

解决方案

You need to add all the View, Store and Model classes in app.js just the same way you added the controller:

controllers: [
        'Main'
],
views : [
    'Home'
]

This should make it work.

这篇关于未捕获-类型错误,不能叩法 - 子 - 的 - 未定义 - 煎茶触摸-all.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆