Sencha touch 未捕获引用错误:未定义connectWin!森查图奇

Sencha touch 未捕获引用错误:未定义connectWin!森查图奇,sencha-touch,undefined-reference,referenceerror,Sencha Touch,Undefined Reference,Referenceerror,以下问题: 我得到了viewClass“connectWin”和controllerClass“connectWinController”。 整个程序以“connectWin”视图开始,因此如果点击“Start”按钮, connectWinController应该隐藏“connectWin”,执行一些操作并打开另一个视图 “订单视图”。但是如果我点击“开始”按钮,我会在控制台上看到错误 代码如下: Ext.Loader.setConfig({ }); Ext.application({

以下问题: 我得到了viewClass“connectWin”和controllerClass“connectWinController”。 整个程序以“connectWin”视图开始,因此如果点击“Start”按钮, connectWinController应该隐藏“connectWin”,执行一些操作并打开另一个视图 “订单视图”。但是如果我点击“开始”按钮,我会在控制台上看到错误

代码如下:

Ext.Loader.setConfig({

});


Ext.application({

    name: 'SenchaDiagApp',



    requires: [
        'Ext.MessageBox',
        'Ext.field.Select',
        'Ext.form.FieldSet',
        'Ext.form.Panel',
        'Ext.Img'
    ],

    refs: {

        connectWin: 'connectWin'
    },  

    launch: function() {
        console.log("App launch!!"); 



         connectWin= {

            layout: 'fit',
                items: [{

                    xtype : 'connectWin'
                }],
            }; 
        Ext.Viewport.add(connectWin);   

    }

});
Ext.define('AM.controller.connectWinController', {

    extend: 'Ext.app.Controller',

    config:{


                refs: {

                connectWin: 'connectWin'

                                 }
            },

    init: function() {

    this.control(
          'connectWin button[action=bestellen]':{

           tap: this.verbindungBestellung 

        },
    },


          verbindungBestellung : function(){
                            console.log("Start");
                connectWin.hide()  **//Now it says: connectWin is not defined?**


                             var orderView = Ext.create('AM.view.orderView');
                             Ext.Viewport.add(orderView);
                    }


        });
                                    '
app.js:

Ext.Loader.setConfig({

});


Ext.application({

    name: 'SenchaDiagApp',



    requires: [
        'Ext.MessageBox',
        'Ext.field.Select',
        'Ext.form.FieldSet',
        'Ext.form.Panel',
        'Ext.Img'
    ],

    refs: {

        connectWin: 'connectWin'
    },  

    launch: function() {
        console.log("App launch!!"); 



         connectWin= {

            layout: 'fit',
                items: [{

                    xtype : 'connectWin'
                }],
            }; 
        Ext.Viewport.add(connectWin);   

    }

});
Ext.define('AM.controller.connectWinController', {

    extend: 'Ext.app.Controller',

    config:{


                refs: {

                connectWin: 'connectWin'

                                 }
            },

    init: function() {

    this.control(
          'connectWin button[action=bestellen]':{

           tap: this.verbindungBestellung 

        },
    },


          verbindungBestellung : function(){
                            console.log("Start");
                connectWin.hide()  **//Now it says: connectWin is not defined?**


                             var orderView = Ext.create('AM.view.orderView');
                             Ext.Viewport.add(orderView);
                    }


        });
                                    '
connectWin

Ext.define('AM.view.connectWin' , {

    extend: 'Ext.Panel',  
    alias : 'widget.connectWin', 


    config:{
        ui : 'light',
        items: [
            {

                 xtype:         'panel',       
                 scrollable:    false,
                 centered:      true,
                 modal:         true,
                 width:         '100%',
                 height:        '50%', 

                    items: [ 

                        {

            xtype:      'titlebar',
                        docked:     'top',
                        height:     '110px',
                id:         'connectTitleID',
                        title:      'Login'
                    },

                {
                        xtype:       'spacer'
                    },




                {
                        xtype:      'titlebar', // 2 Titlebar unten 
                        docked:     'bottom',
                        height:     '110px',

                              items:[                       

                               {   
                                     xtype:     'button',
                                     align:     'left',
                     height:    '100px',
                     width: '200px',
                                     action:     'bestellen',
                     text:      'Start',
                                   }],


            }],              
        },
    }); 
连接WinController:

Ext.Loader.setConfig({

});


Ext.application({

    name: 'SenchaDiagApp',



    requires: [
        'Ext.MessageBox',
        'Ext.field.Select',
        'Ext.form.FieldSet',
        'Ext.form.Panel',
        'Ext.Img'
    ],

    refs: {

        connectWin: 'connectWin'
    },  

    launch: function() {
        console.log("App launch!!"); 



         connectWin= {

            layout: 'fit',
                items: [{

                    xtype : 'connectWin'
                }],
            }; 
        Ext.Viewport.add(connectWin);   

    }

});
Ext.define('AM.controller.connectWinController', {

    extend: 'Ext.app.Controller',

    config:{


                refs: {

                connectWin: 'connectWin'

                                 }
            },

    init: function() {

    this.control(
          'connectWin button[action=bestellen]':{

           tap: this.verbindungBestellung 

        },
    },


          verbindungBestellung : function(){
                            console.log("Start");
                connectWin.hide()  **//Now it says: connectWin is not defined?**


                             var orderView = Ext.create('AM.view.orderView');
                             Ext.Viewport.add(orderView);
                    }


        });
                                    '

app.js
中声明您在应用程序中使用的每个视图、控制器、模型和存储:

Ext.application({       
    name: 'AppName',
    requires: [],
    models:['Model-1','Model-2'],
    controllers : ['Main'],
    views : ['View-1','View-2'],
    stores : [ 'Store-1' , 'Store-2'],

    launch : function() {
        Ext.fly('appLoadingIndicator').destroy();
        Ext.Viewport.add({
            xclass: 'AppName.view.View-1',
            autoDestroy: false,
            showAnimation:false
        });

    }
});

在控制器中,要获取视图的引用

参考:{

connectWin:{autoCreate:true,选择器:'#connectWin',xtype:'connectWin'}

}

使用xtype:'connectWin'而不是别名