zoukankan      html  css  js  c++  java
  • js url 参数 转换成 json 对象数据

    some=params&over=here => {"some":"params","over":"here"}
    

      

    var params = getUrlVars('some=params&over=here');
    console.log(params);
    
    function getUrlVars(url) {
        var hash;
        var myJson = {};
        var hashes = url.slice(url.indexOf('?') + 1).split('&');
        for (var i = 0; i < hashes.length; i++) {
            hash = hashes[i].split('=');
            myJson[hash[0]] = hash[1];
        }
        return myJson;
    }
    

      

  • 相关阅读:
    8.25
    8.24
    8.23
    8.22
    8.21
    8.20
    8.19
    8.18
    8.17
    8.16
  • 原文地址:https://www.cnblogs.com/codedreams/p/9664724.html
Copyright © 2011-2022 走看看