0

每当我创建一个带有 url 的组件时,Ext Js 4 都会将 ?undefined 添加到链接中。我怎样才能摆脱它?

Ext.onReady(function() {
                Ext.create('Ext.toolbar.Toolbar', {"items":[{"text":"Dashboard","xtype":"button","target":"_self","href":"https:\/\/domain.tld\/admin\/"},{"text":"Categories","xtype":"button","menu":{"items":[{"text":"New","xtype":"button","target":"_self","href":"https:\/\/domain.tld\/admin\/category\/create\/"}]}}],"renderTo":"admin_menu","width":"100%"});
            });

单击仪表板会将您带到https://domain.tld/admin/dashboard?undefined

4

2 回答 2

1

我查看了源代码以了解它是如何创建 url 的。它采用 href 配置并附加 params 配置,而不检查是否定义了 params。然后附加 baseParams 配置。因此,如果您想要一个没有查询字符串的链接,请使用空参数配置创建您的按钮。

Ext.create("Ext.button.Button", {href: 'www.google.com', params:'',text:'Link',target:'_self'});

于 2011-04-29T15:27:08.030 回答
0

ExtJS 文档没有提到href工具栏支持的配置选项。

我建议指定一个处理函数,而不是指定targetand 。href效果如下:


{
  text:'Dashboard',
  handler:function(){
    //window.open(...) or window.location.href=...
  }
//...
}
于 2011-04-27T22:03:44.333 回答