如何将标题更改为H2标签

How to change the title to H2 tag

我有一个呈现动态标题的页面。当我使用 HeaderCfg 将标题更改为 h2 时,它是在 span 标记中嵌套元素,如下所示

<h2 class=" x-unselectable">
  <span class="x-panel-header-text">This is Title</span>
</h2>

预计:

<h2 class=" x-unselectable x-panel-header-text">This is Title</h2>

代码:

myForm = new Ext.FormPanel({
    title : Orginal.orginalTitle.get('get-title'),
    headerCfg: {
                tag: 'h2',
                },
    id : 'title-field',
});

版本:3.4.0

您最初可以将标题设置为:

title: '<h2>mytitle</h2>'

结合面板覆盖:

        setTitle : function(title, iconCls){
            title = `<h2>${title}</h2>`;

            this.title = title;
            if(this.header && this.headerAsText){
                this.header.child('span').update(title);
            }
            if(iconCls){
                this.setIconClass(iconCls);
            }
            this.fireEvent('titlechange', this, title);
            return this;
        }