在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML5  HTML/ vue小白提問 axios怎么捕獲請求異常

vue小白提問 axios怎么捕獲請求異常

請問各位大佬 這樣寫規(guī)范么 有更好的建議么?
圖片描述

`
axios

                .post("/au/api/rulereleaseapply/findAllPubTask", {
                     branchCode: userInfor[0].branchCode,
                     userCode: userInfor[0].userCode,
                     busiinfoFive: "11"
                })
                .then(response => {
                    if (response.data.success) {
                      debugger;
                        console.log("審核數(shù)據(jù)=>", response.data);
                        _this.ruleReleaseVertifyData = response.data.entity.items;
                        loading.close();
                    } else {
                        loading.close();
                        this.$message({
                            showClose: true,
                            message: response.data.errorMessage,
                            type: "error"
                        });
                    }
                }).catch(response =>{
                  console.log('err',response);
                   loading.close();
                   loading.close();
                        this.$message({
                            showClose: true,
                            message: response.message,
                            type: "error"
                        });
                })

`

回答
編輯回答
孤慣

then 里面出現(xiàn)了語法錯誤,拋出異常,也會走到 catch() 回調里面吧,不一定時 是 網(wǎng)絡錯誤。

2017年8月9日 23:15
編輯回答
不二心

規(guī)范,但是可以用攔截器axios.interceptors.requestaxios.interceptors.response實現(xiàn),不然真的太累了。

提問最好貼代碼而不是貼圖

2018年8月14日 01:15