Sencha touch ¨;如何通过在inxt.getCmp(';myPanelID';)中使用面板的id获取面板来动态设置面板的标题,设置标题的属性有哪些

Sencha touch ¨;如何通过在inxt.getCmp(';myPanelID';)中使用面板的id获取面板来动态设置面板的标题,设置标题的属性有哪些,sencha-touch,extjs,sencha-touch-2,Sencha Touch,Extjs,Sencha Touch 2,我有一个Ext面板,我想从某个变量设置面板的标题 我有面板的id,需要从中设置面板的标题 我在找这样的东西 Ext.define('Myapplication.view.Contacts', { extend: 'Ext.Panel', alias: 'widget.Contacts', id: 'myPanelID', ... html: '<div>Your Title</div>', ... initCom

我有一个Ext面板,我想从某个变量设置面板的标题

我有面板的
id
,需要从中设置面板的标题

我在找这样的东西

Ext.define('Myapplication.view.Contacts', {
    extend: 'Ext.Panel',
    alias: 'widget.Contacts',
    id: 'myPanelID',
    ...

    html: '<div>Your Title</div>',
    ...

    initComponent: function(component, options, wstitle) {
        Ext.getCmp('myPanelID').setHtml('<div>Another Title</div>');
    }
})
Ext.getCmp('myPanel').setTitle()像阿曲布他

Ext.define('Myapplication.view.Contacts', {
    extend: 'Ext.Panel',
    alias: 'widget.Contacts',
    id: 'myPanelID',
    ----
    -----
    ------
    -----

    listeners: [
        {
           fn: 'initComponent',
           event: 'initialize'
        }
    ]
},
initComponent: function(component, options, wstitle) {
    Ext.getCmp('myPanelID').header.title = ('Title of panel'); //Not working
    Ext.getCmp('myPanelID').setTitle= ('Title of panel'); //Not working
}
总是有一个错误:

TypeError:“undefined”不是对象(计算“Ext.getCmp('myPanel').setTitle')
Ext.getCmp('myPanelID')。setTitle
是一个函数

所以

Ext.getCmp('myPanelID').setTitle('panel Title')


是您要查找的内容

您遇到语法错误。你写

Ext.getCmp('myPanelID').setTitle= ('Title of panel'); //Not working
删除=字符

Ext.getCmp('myPanelID').setTitle('Title of panel'); //Works like a charm

干杯,Oleg是一个容器,而不是一个对象。如果你想改变某人,比如
标题
,你可以尝试这样的方法

Ext.define('Myapplication.view.Contacts', {
    extend: 'Ext.Panel',
    alias: 'widget.Contacts',
    id: 'myPanelID',
    ...

    html: '<div>Your Title</div>',
    ...

    initComponent: function(component, options, wstitle) {
        Ext.getCmp('myPanelID').setHtml('<div>Another Title</div>');
    }
})
Ext.define('Myapplication.view.Contacts'{
扩展:“Ext.Panel”,
别名:“widget.Contacts”,
id:'myPanelID',
...
html:'你的标题',
...
initComponent:函数(组件、选项、wstitle){
Ext.getCmp('myPanelID').setHtml('other Title');
}
})

希望这些有帮助。:)

在本例中,还出现了一个错误TypeError:“undefined”不是对象(正在计算“Ext.getCmp('myPanel').setTitle'))