utils.js 277 B

1234567891011121314
  1. export function param2Obj(url) {
  2. const search = url.split('?')[1]
  3. if (!search) {
  4. return {}
  5. }
  6. return JSON.parse(
  7. '{"' +
  8. decodeURIComponent(search)
  9. .replace(/"/g, '\\"')
  10. .replace(/&/g, '","')
  11. .replace(/=/g, '":"') +
  12. '"}'
  13. )
  14. }