url 地址处理(截取,参数等) (js实例-5)
程序员文章站
2024-03-02 13:31:22
...
function hrefObj() {
var localhref = window.location.href;
var localarr = localhref.split('?')[1].split('&');
console.log(localarr)
var tempObj = {};
for (var i = 0; i < localarr.length; i++) {
tempObj[localarr[i].split('=')[0]] = localarr[i].split('=')[1];
console.log(i)
}
return tempObj;
}
// 截取地址参数
function getCode() {
var aId = window.location.href.split('?')[1].split('=')[1];
return aId;
}
截取地址字符串分隔
// var openid = $state.params.openid;
var paramsArr = location.href.match(/\?\S+/)[0].replace('?', '').split('&');
vm.params = {};
for (var i = 0; i < paramsArr.length; i++) {
var tmp = paramsArr[i].split('=');
vm.params[tmp[0]] = tmp[1];
}
var urlStr = window.location.href.split('?')[1].split('&')[0].split('=')[1]
上一篇: mybatisPlus 条件构造器