<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ``` function getUrl(type){ var url=window.location.href; var param; if (url.indexOf('?') != -1) { url=url+'&solution_type='+type; } else { url=url+'?solution_type='+type; } console.log(url) } ``` 獲取當前頁面指定的get請求參數 ``` //獲取url中的參數 不存在返回null function getUrlParam(name) { //封裝方法 var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //構造一個含有目標參數的正則表達式對象 var r = window.location.search.substr(1).match(reg); //匹配目標參數 if (r != null) return decodeURI(r[2]); return null; //返回參數值 } ``` ### window.location: window的location對象 1. window.location.href   整個URl字符串(在瀏覽器中就是完整的地址欄) 2. window.location.protocol   URL 的協議部分   返回值:http: 3. window.location.host   URL 的主機部分(帶端口號) 4. window.location.port   URL 的端口部分。 5.window.location.pathname   URL 的路徑部分(就是文件地址) 5. window.location.search   查詢(參數)部分。得到的是url中?部分。除了給動態語言賦值以外,我們同樣可以給靜態頁面,并使用javascript來獲得相信應的參數值。 6. window.location.hash   錨點。得到的是url中#部分。 ### substr() 返回一個從指定位置開始的指定長度的子字符串 這里設置為1,是為了把url中的?號去掉 ### reg ~~~jsx function getQueryString(name) { var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); //(^|&)education_serve_type=([^&]*)(&|$) 《=》?cate=1&education_serve_type=1 var r = window.location.search.substr(1).match(reg); alert(r)//&education_serve_type=1,&,1, alert(decodeURI(r[0]))//&education_serve_type=1 alert(decodeURI(r[1]))//& alert(decodeURI(r[2]))//1 if (r != null) { return unescape(r[2]); } return null; } ~~~ 1、reg是一個正則表達式子,是你獲得的參數 ![](https://img.kancloud.cn/c3/95/c3957b5e8446335772cd98f44422657b_1200x403.png) var reg = new RegExp("(^|&)"+ name +"=(\[^&\]\*)(&|$)"); (^| )代表開始 ( |$)代表結束 以&或者$結尾的字符串 這個正則是尋找&+url參數名字=值+& &可以不存在。 2. window.location.search.substr(1).match(reg); (1) location是包含了相關的url的信息,它是windown的一部分。 (2) search是一個可以查詢的屬性,可以查詢?之后的部分。 (3) substr(1)是為了去掉第一個? (4) match()是你要匹配的部分 后面可以是正則表達式。 (5) return unescpe(r\[2\]) 返回的值 一個數組。 (6) 這里是開始匹配,找到了返回對應url值,沒找到返回null。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看