【问题标题】:Reading query parameter in a URL with Ext JS version 4.2.1使用 Ext JS 版本 4.2.1 读取 URL 中的查询参数
【发布时间】:2020-07-08 13:43:57
【问题描述】:
我正在使用 Ext JS 4.2.1 版本,使用模型存储视图控制器架构。我有一个场景,服务器端将发送带有查询参数的 URL。例如,假设 https://ascasc/asda/asdas 是我的页面,服务器将点击/调用此 URL,他们将发送查询参数作为此 URL 获取请求的一部分。
- 我需要读取控制器中的查询参数,有没有ext js提供的函数/方法或者我需要使用JS函数
getParameterByName?
- 或者我需要使用
var params = new URLSearchParams(window.location.search)?
- 还有其他方法吗?
【问题讨论】:
标签:
extjs
extjs4
extjs4.1
extjs4.2
【解决方案1】:
Ext.Object.fromQueryString("foo=1&bar=2"); // returns {foo: '1', bar: '2'}
Ext.Object.fromQueryString("foo=&bar=2"); // returns {foo: null, bar: '2'}
Ext.Object.fromQueryString("some%20price=%24300"); // returns {'some price': '$300'}
Ext.Object.fromQueryString("colors=red&colors=green&colors=blue"); // returns {colors: ['red', 'green', 'blue']}
Doc