url

75次阅读

共计 359 个字符,预计需要花费 1 分钟才能阅读完成。

var url = "www.baidu.com";
function getKey(key){let urls = url.split('?')[1]?url.split('?')[1]:'';
    if(!urls){console.log('没有参数');
        return;
    }
    let arrKeys = urls.split('&');
    var arr,name,value,flag;
    for(var i in arrKeys){arr = arrKeys[i].split("=");
        name = arr[0];
        value = arr[1];
        if(key == name){return value;};
        console.log(i,arrKeys.length-1)
        if(i == arrKeys.length-1){return "无此参数"}
    }
};
getKey('aa')

正文完
 0