如何使用Sencha Touch获取Url参数

时间:2011-08-20 01:54:28

标签: extjs sencha-touch sencha-charts

如何从网址获取参数?例如,如果有:

page1.html#token=12345 

我需要从网址获取token,我怎么能在sencha中做到这一点?

3 个答案:

答案 0 :(得分:2)

www.test.com/?drink=beer

var params = Ext.urlDecode(location.search.substring(1));
//substring(1) removes the question mark

console.log(params);
//Get the value of a key by using:
console.log(params.drink);

答案 1 :(得分:0)

最佳解决方案是使用Sencha的内置路由功能,并将您的参数作为单独的URI段传递,即www.webapp.com/user/param1/param2。这样可以获得更清晰的URI,您可以使用Sencha的map.connect()来设置路由。

答案 2 :(得分:0)

Ext.urlDecode( “令牌= 12345”); //返回{token:“12345”}