久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      • <bdo id='uQaOX'></bdo><ul id='uQaOX'></ul>
      <tfoot id='uQaOX'></tfoot>

      <legend id='uQaOX'><style id='uQaOX'><dir id='uQaOX'><q id='uQaOX'></q></dir></style></legend>

      <i id='uQaOX'><tr id='uQaOX'><dt id='uQaOX'><q id='uQaOX'><span id='uQaOX'><b id='uQaOX'><form id='uQaOX'><ins id='uQaOX'></ins><ul id='uQaOX'></ul><sub id='uQaOX'></sub></form><legend id='uQaOX'></legend><bdo id='uQaOX'><pre id='uQaOX'><center id='uQaOX'></center></pre></bdo></b><th id='uQaOX'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='uQaOX'><tfoot id='uQaOX'></tfoot><dl id='uQaOX'><fieldset id='uQaOX'></fieldset></dl></div>

        <small id='uQaOX'></small><noframes id='uQaOX'>

      1. 處理 400 后的運行時錯誤

        Runtime Error after handling 400(處理 400 后的運行時錯誤)

        <i id='SgGpM'><tr id='SgGpM'><dt id='SgGpM'><q id='SgGpM'><span id='SgGpM'><b id='SgGpM'><form id='SgGpM'><ins id='SgGpM'></ins><ul id='SgGpM'></ul><sub id='SgGpM'></sub></form><legend id='SgGpM'></legend><bdo id='SgGpM'><pre id='SgGpM'><center id='SgGpM'></center></pre></bdo></b><th id='SgGpM'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='SgGpM'><tfoot id='SgGpM'></tfoot><dl id='SgGpM'><fieldset id='SgGpM'></fieldset></dl></div>
            <tbody id='SgGpM'></tbody>
          • <small id='SgGpM'></small><noframes id='SgGpM'>

            <tfoot id='SgGpM'></tfoot>
              <bdo id='SgGpM'></bdo><ul id='SgGpM'></ul>
              • <legend id='SgGpM'><style id='SgGpM'><dir id='SgGpM'><q id='SgGpM'></q></dir></style></legend>

                  本文介紹了處理 400 后的運行時錯誤的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  場景:

                  用戶名和密碼使用 WebApi 2 令牌身份驗證進行身份驗證.如果憑據正確,則返回令牌.但是,如果憑據不正確,則會返回 400 bad request.在我的 Ionic 2 項目中,如果我得到響應,我會導航到下一頁.如果我收到錯誤,我會顯示我的自定義錯誤消息.

                  The username and password is authenticated using WebApi 2 token authentication. If the credentials are correct, then token is returned. But, if the credentials are incorrect, 400 bad request is returned. In my Ionic 2 project, if I get the response, I navigate to the next page. If I get the error, I show my custom error message.

                  問題:

                  我面臨的問題是,如果我第一次輸入錯誤的憑據,則會顯示自定義錯誤消息.如果我再次輸入錯誤的憑據,自定義錯誤消息將與離子錯誤消息一起顯示.

                  The issue I'm facing is, if I enter the wrong credentials for the first time, the custom error message is shown. If I enter wrong credentials again, the custom error message is shown along with the ionic error message.

                  這是我的代碼:

                  login.ts

                    doLogin() {
                      if (this.Username !== undefined && this.Password !== undefined) {
                        this.loading.present();
                        this.authSrv.login(this.Username, this.Password).subscribe(data => {
                          this.navCtrl.setRoot('HomePage');
                          this.loading.dismiss();
                        }, (err) => {
                          this.errorMsg("Invalid Username/Password !" + err);
                          this.loading.dismiss();
                        });
                      }
                      else
                        this.errorMsg("Please enter Username/Password");
                    }
                  

                  auth-service.ts

                  auth-service.ts

                    login(username, password) {
                      let headers = new Headers();
                      headers.append('Content-Type', 'application/x-www-form-urlencoded');
                      let urlSearchParams = new URLSearchParams();
                      urlSearchParams.append('username', username);
                      urlSearchParams.append('password', password);
                      urlSearchParams.append('grant_type', 'password');
                      let body = urlSearchParams.toString()
                      return this.http.post('http://' + this._api + '/postoken', body, { headers: headers }
                      )
                        .map(res => res.json())
                        .map((res) => {
                          if (res !== null) {
                            localStorage.setItem('acess_token', res["access_token"]);
                            localStorage.setItem('access_type', res["access_type"]);
                            localStorage.setItem('expires_in', res["expires_in"]);
                            this.loggedIn = true;
                          }
                          return res;
                        });
                    }
                  

                  截圖:

                  錯誤

                  任何建議都會有所幫助.

                  Any advice would be helpful.

                  推薦答案

                  LoadingController 只能調用一次.

                  請注意,組件關閉后,將不再可用,必須創建另一個組件.

                  Note that after the component is dismissed, it will not be usable anymore and another one must be created.

                  這是導致異常的原因.您應該每次在 doLogin 中創建新的加載.

                  This is causing the exception. You should create new loading everytime in doLogin.

                  doLogin() {
                      if (this.Username !== undefined && this.Password !== undefined) {
                        this.loading = this.loadingCtrl.create({ //create here
                      content: 'Please wait...'
                       });
                        this.loading.present();
                        this.authSrv.login(this.Username, this.Password).subscribe(data => {
                          this.navCtrl.setRoot('HomePage');
                          this.loading.dismiss();
                        }, (err) => {
                          this.errorMsg("Invalid Username/Password !" + err);
                          this.loading.dismiss();
                        });
                      }
                      else
                        this.errorMsg("Please enter Username/Password");
                    }
                  

                  這篇關于處理 400 后的運行時錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數據更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態元素 - Angular 2 amp;離子2)
                    • <bdo id='5Bebq'></bdo><ul id='5Bebq'></ul>

                        <i id='5Bebq'><tr id='5Bebq'><dt id='5Bebq'><q id='5Bebq'><span id='5Bebq'><b id='5Bebq'><form id='5Bebq'><ins id='5Bebq'></ins><ul id='5Bebq'></ul><sub id='5Bebq'></sub></form><legend id='5Bebq'></legend><bdo id='5Bebq'><pre id='5Bebq'><center id='5Bebq'></center></pre></bdo></b><th id='5Bebq'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5Bebq'><tfoot id='5Bebq'></tfoot><dl id='5Bebq'><fieldset id='5Bebq'></fieldset></dl></div>

                      1. <legend id='5Bebq'><style id='5Bebq'><dir id='5Bebq'><q id='5Bebq'></q></dir></style></legend>
                          <tfoot id='5Bebq'></tfoot>
                            <tbody id='5Bebq'></tbody>

                            <small id='5Bebq'></small><noframes id='5Bebq'>

                            主站蜘蛛池模板: 久久9999久久| 日韩精品中文字幕一区二区三区 | 久久精点视频 | 日本五月婷婷 | 夜久久| 国产剧情一区 | 天天久久| 人人九九精| 91麻豆精品一区二区三区 | 午夜精品久久久久久久星辰影院 | av色站 | 午夜影视在线观看 | 亚洲欧美男人天堂 | 91最新在线视频 | 国产成人久久精品一区二区三区 | 99视频在线免费观看 | 一区二区免费看 | av天天看| 日本一区二区三区四区 | 三级av在线| 国产精品中文字幕在线观看 | 久久99久久| 国产一区二区自拍 | 日韩高清黄色 | 欧美精品在线播放 | 黄频免费| 久久69精品久久久久久久电影好 | 中国黄色毛片视频 | 中文字幕亚洲一区二区三区 | 国产乱码精品一区二区三区中文 | 亚洲国产成人精品女人久久久 | 一二三四av | 91免费在线看 | aaaa日韩| 一级高清视频 | 国产成人综合久久 | 97操操| 久久久久亚洲国产| 91亚洲国产成人精品一区二三 | 成年人黄色一级毛片 | 91精品国产综合久久国产大片 |