-->

未捕获-类型错误,不能叩法 - 子 - 的 - 未定义 - 煎茶触摸-all.js(Uncaught

2019-10-28 20:11发布

我是新来煎茶触摸,虽然我对MVC一知半解,我得到一个错误,而我试图打造继煎茶的视频教程触摸2作为一个应用程序:

遗漏的类型错误:无法调用未定义的煎茶触摸-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,它工作正常,但是当我定义视图,并尝试从的xtype到app.js访问视图它不工作,抛出上述例外,尽管它记录在控制台成功在控制器传递该消息。

浏览器中使用:Chrome浏览器

IDE:集锦

煎茶触摸版本:2.0

Answer 1:

您需要添加在用同样的方法添加的控制器app.js所有查看,存储和模型类:

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

这应该使它发挥作用。



文章来源: Uncaught-TypeError-Cannot-call-method-substring-of-undefined-sencha-touch-all.js