data() {
return {
reqs:{},
};
},
created() {
let url = "http://wechatxxx.dazhi100.com/xxx.html?uid=111&ut=1&ct=123&io=1&img=11.jpg&n=小宝&s=学校&d=201";
this.reqs = this.getRequest(url);
console.log("this.reqs", this.reqs);
},
methods: {
getRequest(url) {
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.split('?')[1];
var strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
return theRequest;
}
}
js获取url中的参数值
于 2020-04-03 10:24:06 首次发布