1. var url = 'https://www.baidu.com/s?id=123&name=why&phone=13876769797';
    2. function getQueryString(name) {
    3. var strs = '';
    4. var index = url.indexOf('?');
    5. if(index!=-1) {
    6. strs = url.substring(index+1).split('&');
    7. }
    8. for (let index = 0; index < strs.length; index++) {
    9. var splitItem = strs[index].split('=');
    10. if(splitItem[0]==name) {
    11. return splitItem[1];
    12. }
    13. }
    14. };
    15. console.log(getQueryString('name'));