码迷,mamicode.com
首页 > 其他好文 > 详细

location记录<18.7.21>

时间:2018-07-21 14:25:42      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:array   ref   目的   返回   arch   字符串   ams   length   new   

 // var index = location.href;
        // console.log(index)
        // // indexOf() 方法可返回某个指定的字符串值在字符串中首次出现的位置。
        // var demo = index.indexOf("?");
        // console.log(demo);
        // // substr() 方法可在字符串中抽取从 start 下标开始的指定数目的字符。
        // // split() 方法用于把一个字符串分割成字符串数组。
        // var arr = index.substr(demo + 1).split("&");
        // console.log(arr);
        // for (var i = 0; i < arr.length; i++) {
        //     var array = arr[i].split("=");
        //     // if (array[0] == ‘a‘) {

        //     // };

        //     // console.log(array[1]);
        //     console.log(array);
        // }



        //原生方法
        var obj = new URLSearchParams(location.search);
        var a = obj.get(‘a‘);
        console.log(a);
        console.log(location.search);
        console.log(obj);

 

location记录<18.7.21>

标签:array   ref   目的   返回   arch   字符串   ams   length   new   

原文地址:https://www.cnblogs.com/zbx-boke/p/9346052.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!