3 Star 54 Fork 14

Yaohaixiao / dom.js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
getURLSearchParams.js 597 Bytes
一键复制 编辑 原始数据 按行查看 历史
/**
* 返回 URL 地址中的查询参数(键/值)对象
* ====================================================
* @method getURLSearchParams
* @param {String} [url] - 可选参数,URL 地址
* @returns {Object}
*/
const getURLSearchParams = (url = location.search) => {
const pattern = /([^?=&]+)(=([^&]*))/g
return (url.match(pattern) || []).reduce((a, v) => {
const index = v.indexOf('=')
const key = v.slice(0, index)
const value = v.slice(index + 1)
return (a[key] = value.replace(/\+/g, ' ')), a
}, {})
}
export default getURLSearchParams
JavaScript
1
https://gitee.com/yaohaixiao/dom.js.git
git@gitee.com:yaohaixiao/dom.js.git
yaohaixiao
dom.js
dom.js
main

搜索帮助