vue获取url参数

vue中由于有/#/等乱七八糟的我也不懂的东西,参数经常获取错误,用下面方法就没错过

var url = window.location.search;
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
var strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
}
}
var entrance = theRequest.entrance ? theRequest.entrance : "";
var basicid = theRequest.basicid ? theRequest.basicid : "";

你可能感兴趣的:(vue获取url参数)