如何将标题更改为H2标签

z2acfund  于 2022-09-26  发布在  其他
关注(0)|答案(1)|浏览(299)

我有一个呈现动态标题的页面。当我使用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

htrmnn0y

htrmnn0y1#

您可以首先将标题设置为:

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;
        }

相关问题