ExtJS 6.x Modern Button as a Link

断了今生、忘了曾经 提交于 2019-12-08 13:29:04

问题


On menu items you are able to optionally add either a handler to handle press or mouseclick events or specify and href configuration so that when the menu is simply a link.

  {
     text: 'Example Ext Menu Item',
     iconCls: 'x-fa fa-cog',
     href: 'https://www.google.com'
  }

For the Ext.Button (Modern) how can you have the button act as a link while still supporting the other features of a button (icons, on hover etc).

For example I would like to be able to "right click" on any area of the button and "open in a new tab".


回答1:


You can wrap the button in a custom element by overriding like this:

Ext.define('MyApp.components.MyButton', {
    extend: 'Ext.Button',
    xtype: 'mybutton',

    element: {
        reference: 'element',
        tag: 'a',
        href: 'http://www.foo.bar'     
    }
});


来源:https://stackoverflow.com/questions/47494458/extjs-6-x-modern-button-as-a-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!