// url格式:index.php?act=exampleAct&op=exampleOp&example_id=10
getUrlParams(){
let url = location.search; //获取url中"?"符后的字符串
let obj = {};
if(url.indexOf('?') != -1){
let str = url.substr(1);
let strs = str.split('&');
strs.forEach(function(item){
let itemArr = item.split('=');
obj[itemArr[0]] = itemArr[1]
})
// 此时obj为url所带的所有参数
this.exampleId = obj.example_id;
}
},
获取url中“?“符后的字符串
最新推荐文章于 2022-03-09 11:05:40 发布