zoukankan      html  css  js  c++  java
  • JavaScript获取url后面的参数

    说明:该方法摘自JavaScript高级程序设计

    function getQueryStringArgs(){
            var qs = (location.search.length > 0 ? location.search.substring(1) : "");
            var args = {};
            var items = qs.length ? qs.split("&") : [];
            var item = null,
                name = null,
                value = null,
                i = 0,
                len = items.length;
            for(i = 0; i< len;i++){
                item = items[i].split("=");
                name = decodeURIComponent(item[0]);
                value = decodeURIComponent(item[1]);
                
                if(name.length){
                    args[name] = value;
                    
                }
            }
            
            return args;
        }

    //获取方式为

    var loanId = getQueryStringArgs()["loanId"];//["loanId"]中的loanId为url后面的参数属性

  • 相关阅读:
    iphoneX 兼容
    app 判断网络状态
    app 版本升级
    express 安装
    app打开QQ与陌生人聊天
    app项目中几个常用的cordvoa插件
    axios请求拦截器和相应拦截器
    vue中MD5+base64加密
    想啥写啥
    react canvas圆环动态百分比
  • 原文地址:https://www.cnblogs.com/baoliwei/p/4353920.html
Copyright © 2011-2022 走看看