ExtJS lookupReference不起作用

VAA*_*AAA 4 extjs extjs6

我想在我的ViewController中使用lookReference但是我无法获得该元素.

这是我的观点:

Ext.define('MyApp.view.main.Main', {
    extend: 'Ext.container.Container',
    xtype: 'app-main',
    requires: [
        'Ext.layout.container.Card',
        'Ext.layout.container.Border',
        'Ext.layout.container.Accordion',
        'Ext.form.Label',
        'MyApp.view.security.LoginForm'
    ],

    controller: 'main',
    reference: 'appmain',


    items: [{xtype: 'loginform', height: 330}]
});
Run Code Online (Sandbox Code Playgroud)

我的LoginForm视图是:

Ext.define('MyApp.view.security.LoginForm', {
    extend: 'Ext.form.Panel'
    title: 'Access',
    items: [
    {
        name: 'userName',
        fieldLabel: "User Name"
    }, {
        inputType: 'password',
        name: 'password',
        fieldLabel: "Password"
    }],
    buttons: [{
        text: 'Log in',
        listeners: {
            click: 'onLoginClick'
        }

    }]
});
Run Code Online (Sandbox Code Playgroud)

这是我的ViewController:

Ext.define('SoftHuman.view.main.MainController', {
    extend: 'Ext.app.ViewController',

    alias: 'controller.main',

    onLoginClick: function(button, e, options) {
        var me = this;

        // show application layout
        var main = me.lookupReference('appmain');

        // HERE main IS NULL... WHY?
    }
});
Run Code Online (Sandbox Code Playgroud)

我有什么问题吗?

Eva*_*oli 6

引用存储在当前结构上方的组件(组件/控制器)上.将引用放在具有控制器的组件上是没有意义的,因为它已经可以通过它访问this.getView().