2

任何人都可以帮助将我的标签制作为 Sencha EXT JS 中的超链接。

4

4 回答 4

1

这是您的问题的解决方案:[Sencha EXT JS 中的超链接]:如何在 extjs4 中创建超链接?

或者您可以为您的标签添加新事件:

Ext.onReady(function() {

    var yourLabel = new Ext.form.Label({
        id:'yourLabel',
        text: 'http://your-link-here.com',
        renderTo : document.body                                

    });

    Ext.getCmp('yourLabel').getEl().on('click',function(){
        window.open("http://your-link-here.com");
    });
});
于 2013-08-27T05:59:32.870 回答
1

你可以告诉 fieldLabel 是一个链接http://jsfiddle.net/EsppR/1/

Ext.create('Ext.form.Panel', {
    title: 'Contact Info',
    renderTo: Ext.getBody(),
    items: {
        xtype: 'textfield',
        name: 'name',
        fieldLabel: '<a href="http://www.google.com">Name</a>',
        allowBlank: false  // requires a non-empty value
    }
});
于 2013-08-27T18:30:11.870 回答
0

作为插件:

Ext.define('YourCompany.plugins.LinkedLabel', {
    extend: 'Ext.AbstractPlugin',
    url: undefined,
    init: function (cmp) {
        this.setCmp(cmp);
        cmp.beforeLabelTextTpl = '<a href="' + url + '">';
        cmp.afterLabelTextTpl = '</a>';
    });
});

利用:

{
    xtype: 'textfield',
    fieldLabel: 'Linked label',
    plugins: Ext.create('YourCompany.plugins.LinkedLabel', { url: '/yourUrl' })
}
于 2015-01-26T15:55:56.990 回答
0

两种方式:

//1st - set html for label
{
   xtype: "label",
   html: "bla bla?! <a href='http:/\tiny.cc/snir' target='_blank'>Press This Link!!!</a><br>"
},

//2nd - create a new component
{
   xtype: 'component',
   autoEl: {
      tag: 'a',
      href: 'http:\/tiny.cc/snir/',
      target: '_blank',
      html: 'tiny.cc/snir'
   }
}

您可以在此处查看我的示例https://fiddle.sencha.com/#view/editor&fiddle/1kqh并检查不同之处。

于 2016-11-21T10:33:43.333 回答