Tips
-
object -> String -> object: JSON.stringify -> encodeURI -> | another page | -> decodeURI -> JSON.parse
-
Use "&" to connect multiple query items in uri;
Code Demo
On page 1:
var filterObj = { year: '2016', pos: '中国' };
var filterStr = JSON.stringify(filterObj);
var enc = encodeURI(filterStr);
console.log(enc);
var myRoute = "/results/2015/pages/1?type=basic&filter=" + enc
Router.go(myRoute);
On page 2:
var queryType = this.params.query.type;
var filterStr = this.params.query.filter;
var dec = decodeURI(filterStr);
var filterObj = JSON.parse(dec);
console.log(filterObj);
Ref
-
matejkramny's answer in String to object in JS;
-
vartec's answer in How to pass multiple parameters in a querystring;