提交 5dd62efe 编写于 作者: Pan's avatar Pan

perf[utils]: add param2Obj function

上级 b6147d33
...@@ -88,3 +88,23 @@ export function formatTime(time, option) { ...@@ -88,3 +88,23 @@ export function formatTime(time, option) {
) )
} }
} }
/**
* @param {string} url
* @returns {Object}
*/
export function param2Obj(url) {
const search = url.split('?')[1]
if (!search) {
return {}
}
return JSON.parse(
'{"' +
decodeURIComponent(search)
.replace(/"/g, '\\"')
.replace(/&/g, '","')
.replace(/=/g, '":"')
.replace(/\+/g, ' ') +
'"}'
)
}
Markdown 格式
0% or
您添加了 0 人 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册 或