<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <script> var str = 'http://item.taobo.com/item.html?a=1&b=2&c=&d=xxx&e'; /* { a:1, b:2, c:'', d:'xxx', e:'' } 1.先截取 'a=1&b=2&c=&d=xxx&e' 2.拆分该字符串 3.变成对象格式 */ var newStr = str.substr(str.indexOf('?')+1); var newArr = newStr.split('&');//["a=1", "b=2", "c=", "d=xxx", "e"] var obj = {}; for(var i=0;i<newArr.length;i++){ var arrs = newArr[i].split('='); obj[arrs[0]] = arrs[1] || ''; } console.log(obj); </script> </body> </html>