<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、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # uniapp封裝網絡請求(post+token) https://blog.csdn.net/weixin_47821281/article/details/108083063?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-17.base&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-17.base ## 先看代碼,復制使用即可,一共三個步驟,具體使用方式下文將清楚羅列,任何新手都可以輕松了解和使用。同時您將為此省下很多寶貴時間。 下面是請求的封裝,您需要在根目錄下新建`Get.js`文件,然后復制以下代碼即可。 ``` // 注釋將會特別詳細,只有您有合理地耐心看完將不會出現問題 function request(method,url, data) { return new Promise((resolve) => { uni.showLoading({ title:'加載中...' }); uni.request({ method: method, url: url, data: data, header: { 'Accept': "*/*", 'content-type': 'application/json;charset=utf-8', 'token': "",//您可根據如本地存儲或者vuex再此處使用邏輯或 來插入token 'Authorization':'',//有的時候這里不一定是 token 還可能是 Authorization }, success(res) { resolve(res) uni.hideLoading() }, fail(err) { uni.showToast({ title: '請求失敗', icon: 'none', duration: 1500, }) uni.hideLoading() } }) }) } function POST(method,url,data) { return request(method,url,data) } module.exports = { POST } ``` ## 接下來是配置調用的方法,我推薦您新建一個API.JS文件,在根目錄或者您習慣的地方,然后復制以下代碼即可 ``` import { POST } from "POST" let base = 'https://www.zhijiaotai.com/education'; //微信登錄 export const WXlogin = params => { return POST('POST',`${base}/WeChat/login`,params).then(res => res.data); }; //通過openid獲取用戶的信息 export const OpenidGetUser = (openId,params) => { return POST('GET',`${base}/User/openid/${openId}`,params).then(res => res.data); }; ``` ## 這是最后一步,在任何您想調用`GetList`這個接口下數據的頁面下復制以下代碼 ``` import { GetList } from "../../Api" //您的api路徑 //然后在您的函數中 或者 onload 測試一下 //請注意 GetList 是個方法,您想傳輸的參數可以這樣設置 不需要參數時不傳即可 onload(){ let params = { name:'姓名' } GetUserMsg(params).then(res=>{ console.log(res) //然后就可以看見您所需要的數據 }) } ```
                  <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>

                              哎呀哎呀视频在线观看