前端知识学习

functiongetParameterByName(name, url) {
    if (!url) url =window.location.href;
    // name =name.replace(/[
]/g, "\\$&"); 这句老是出错,猜测是用来去掉一些斜线的,先注释掉

    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return'';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}