<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ### wx.request(OBJECT) 發起網絡請求。**使用前請先閱讀說明**。 **OBJECT參數說明:** | 參數名 | 類型 | 必填 | 默認值 | 說明 | 最低版本 | | ------------ | ------------------------- | ---- | ---- | ---------------------------------------- | ---------------------------------------- | | url | String | 是 | | 開發者服務器接口地址 | | | data | Object/String/ArrayBuffer | 否 | | 請求的參數 | | | header | Object | 否 | | 設置請求的 header,header 中不能設置 Referer。 | | | method | String | 否 | GET | (需大寫)有效值:OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT | | | dataType | String | 否 | json | 如果設為json,會嘗試對返回的數據做一次 JSON.parse | | | responseType | String | 否 | text | 設置響應的數據類型。合法值:text、arraybuffer | [1.7.0](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/compatibility.html) | | success | Function | 否 | | 收到開發者服務成功返回的回調函數 | | | fail | Function | 否 | | 接口調用失敗的回調函數 | | | complete | Function | 否 | | 接口調用結束的回調函數(調用成功、失敗都會執行) | | **success返回參數說明:** | 參數 | 類型 | 說明 | 最低版本 | | ---------- | ------------------------- | ------------------------------ | ---------------------------------------- | | data | Object/String/ArrayBuffer | 開發者服務器返回的數據 | | | statusCode | Number | 開發者服務器返回的 HTTP 狀態碼 | | | header | Object | 開發者服務器返回的 HTTP Response Header | [1.2.0](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/compatibility.html) | **data 數據說明:** 最終發送給服務器的數據是 String 類型,如果傳入的 data 不是 String 類型,會被轉換成 String 。轉換規則如下: - 對于 `GET` 方法的數據,會將數據轉換成 query string(encodeURIComponent(k)=encodeURIComponent(v)&encodeURIComponent(k)=encodeURIComponent(v)...) - 對于 `POST` 方法且 `header['content-type']` 為 `application/json` 的數據,會對數據進行 JSON 序列化 - 對于 `POST` 方法且 `header['content-type']` 為 `application/x-www-form-urlencoded` 的數據,會將數據轉換成 query string (encodeURIComponent(k)=encodeURIComponent(v)&encodeURIComponent(k)=encodeURIComponent(v)...) **示例代碼:** ``` wx.request({ url: 'test.php', //僅為示例,并非真實的接口地址 data: { x: '' , y: '' }, header: { 'content-type': 'application/json' // 默認值 }, success: function(res) { console.log(res.data) } }) ``` **返回值:** > 基礎庫 1.4.0 開始支持,低版本需做[兼容處理](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/compatibility.html) 返回一個 `requestTask` 對象,通過 `requestTask`,可中斷請求任務。 **requestTask 對象的方法列表:** | 方法 | 參數 | 說明 | 最低版本 | | ----- | ---- | ------ | ---------------------------------------- | | abort | | 中斷請求任務 | [1.4.0](https://mp.weixin.qq.com/debug/wxadoc/dev/framework/compatibility.html) | **示例代碼:** ``` const requestTask = wx.request({ url: 'test.php', //僅為示例,并非真實的接口地址 data: { x: '' , y: '' }, header: { 'content-type': 'application/json' }, success: function(res) { console.log(res.data) } }) requestTask.abort() // 取消請求任務 ``` #### Bug & Tip 1. `tip`: content-type 默認為 'application/json'; 2. `tip`: url 中不能有端口; 3. `bug`: 開發者工具 `0.10.102800` 版本,`header` 的 `content-type` 設置異常;
                  <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>

                              哎呀哎呀视频在线观看