EXT JS 4 将查询字符串添加到链接
每当我创建带有 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
Whenever I create a component with a url, Ext Js 4 is adding ?undefined to the link. How can I get rid of that?
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%"});
});
Clicking dashboard takes you to https://domain.tld/admin/dashboard?undefined
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我查看了源代码以了解它是如何创建 url 的。它采用 href 配置并附加 params 配置,而不检查 params 是否已定义。然后附加 baseParams 配置。因此,如果您想要一个不带查询字符串的链接,请使用空参数配置创建按钮。
Ext.create("Ext.button.Button", {href: 'www.google.com', params:'',text:'Link',target:'_self'});
I looked at the source to figure out how it was creating urls. It takes the href config and appends the params config without checking to see if params is defined. Then appends the baseParams config. So if you want a link without the query string, create your button with an empty params config.
Ext.create("Ext.button.Button", {href: 'www.google.com', params:'',text:'Link',target:'_self'});
ExtJS 文档 没有提及
href
作为工具栏支持的配置选项。我建议指定一个处理函数,而不是指定
target
和href
。一些效果:ExtJS documentation doesn't mention
href
as a supported config option for Toolbar.Instead of specifying
target
andhref
, I suggest specifying a handler function. Something to the effect of :