【问题标题】:How to format a label in ExtJS to look like a link如何在 ExtJS 中将标签格式化为看起来像一个链接
【发布时间】:2021-04-13 15:21:45
【问题描述】:

如何格式化标签以显示 extjs 中的链接? 我不想拥有链接功能(去特定的href)。我只想有一个看起来像一个链接的经典按钮并有点击监听器。

我已尝试使用以下代码:

{
  xtype: 'box',
  autoEl: {tag: 'a', href: 'http://www.google.com', html: 'Google'}
}

但是,这是经典链接。

我也试过

{
xtype: 'box',
html: '<a href="" class="link-forgot-password"> Forgot Password ?/a>'
}

看起来不错,但缺少的是监听器。

【问题讨论】:

    标签: button extjs hyperlink


    【解决方案1】:

    类似这样的:

    {
        xtype: 'box',
        html: '<a href="#" class="link-forgot-password"> Forgot Password ?/a>',
        listeners: {
            el: {
                click: function () {
                    console.log('click');
                },
                scope: this
            }
        }
    }
    

    【讨论】:

    • 谢谢亚瑟。问题是它确实会触发点击事件,但之后它会重新加载我的应用程序。这就是我放 href="" 的原因。我该如何预防?
    • 看看 extjs 中的 xtemplates。
    • 我不知道,我没有看到你的代码。在单独的线程中提供一些小提琴示例。
    • 这是另一个问题,请打开新的“问题”。
    猜你喜欢
    • 2012-08-02
    • 1970-01-01
    • 2021-08-24
    • 2011-07-04
    • 2010-10-17
    • 2013-01-03
    • 2012-01-11
    • 2021-02-08
    • 1970-01-01
    相关资源
    最近更新 更多