Comparing version 1.0.1 to 1.0.2
@@ -6,7 +6,5 @@ | ||
let param = 'school=gongda&hobby=skating&number=3' | ||
let jsonObj = queryToObj(param) | ||
console.log(jsonObj) | ||
输出:{ | ||
@@ -61,5 +59,30 @@ school: 'gongda', | ||
/* | ||
直接取url中的参数转为json(或者不转) | ||
用法: | ||
let para = urlToJson() | ||
console.log(para) | ||
* */ | ||
function urlToJson () { | ||
const url = window.location.href | ||
const reg = /\?.*$/ // 正则取'?后的参数' | ||
const urlMatch = url.match(reg) | ||
// 匹配去掉?的纯参数(正则精髓,贪婪永远匹配最后一个?后的参数) | ||
const param = urlMatch && urlMatch.length ? urlMatch[0].replace(/^\?*.*\?/, '') : '' | ||
const output = { | ||
paramStr: param, | ||
paramJson: queryToObj(param) | ||
} | ||
return output | ||
} | ||
export { | ||
queryToObj, | ||
toQueryString | ||
toQueryString, | ||
urlToJson | ||
} |
{ | ||
"name": "cao_tour", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "the useful function of js", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
32652
1038
0