zoukankan      html  css  js  c++  java
  • js获取url的各项参数

     function getQueryStringArgs() {
    
                //取得查询字符串并去掉开头的问号
                var qs = location.search.length > 0 ? location.search.substring(1) : "",
    
                //保存数据对象
                args = {},
    
                //取得每一项
                items = qs.length ? qs.split("&") : [],
                item = null,
                name = null,
                value = null,
    
                //在for循环中使用
                i = 0,
                len = items.length;
    
                //逐个将每一项添加到args中
                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;
            }

    参考《javascript高级程序设计》

  • 相关阅读:
    ElementUi
    Vue插件
    Vue-cli
    Vue进阶
    Vue组件
    Vue生命期钩子
    Vue基础
    Vue介绍
    logging模块
    time模块
  • 原文地址:https://www.cnblogs.com/scnuwangjie/p/6022323.html
Copyright © 2011-2022 走看看