JavaScript获取url参数

╰+攻爆jí腚メ 2022-01-19 05:55 409阅读 0赞
  1. const getParams = () => {
  2. let params = {};
  3. let str = window.location.hash || window.location.search;
  4. str.slice(1).split('&').forEach((item) => params[item.split('=')[0]] = item.split('=')[1]);
  5. return params
  6. };
  7. 复制代码

转载于:https://juejin.im/post/5cb5c4b66fb9a0688d2e4044

发表评论

表情:
评论列表 (有 0 条评论,409人围观)

还没有评论,来说两句吧...

相关阅读