JavaScript 获取url里面携带的参数
作者:互联网
const getParameters = (URL) => {
URL = JSON.parse('{"' + decodeURI(URL.split("?")[1]).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') +'"}');
return JSON.stringify(URL);
};
console.log(getParameters('http://localhost:8080/#/projectpage?id=7098&Vid=344&type=2'))
运行结果:
标签:url,携带,JavaScript,replace,parse,URL,JSON,getParameters 来源: https://blog.csdn.net/HH18700418030/article/details/121233300