From c0d0527f302757caf62b98bc53be0819b0e93c53 Mon Sep 17 00:00:00 2001 From: liyang <1711467488@qq.com> Date: Mon, 27 Aug 2018 13:47:11 +0800 Subject: [PATCH] =?UTF-8?q?http=20=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 2dd211d2d907008d183137f70427aa9e09911d3a [formerly 2dd211d2d907008d183137f70427aa9e09911d3a [formerly 2dd211d2d907008d183137f70427aa9e09911d3a [formerly 2dd211d2d907008d183137f70427aa9e09911d3a [formerly 3513cac69ee4f88639864b6948d2cc92fa905d12 [formerly 9d47a62c0bf21043a3a033ca2986dd7e0e498fde]]]]] Former-commit-id: 19f33fa3135a4dee8c26877c4c2f0806d3bb12f9 Former-commit-id: 8817aeb5ff39ee8e0f1c0c6bc4e99e15be719d14 Former-commit-id: 4a03ffc59182705c1e32cc39a3b58bd4f99cab3f [formerly c3df7a16c661750c70f9d958b77e41859741cef2] Former-commit-id: 507e7b5131fd2c7ebb015e2da0c0ed38699b7aaa Former-commit-id: a3d6f974fee73c06f92f4bc834f21f4b844cc370 Former-commit-id: 10afc53093bf44b398b5f8f7560b9b9cd231d05e Former-commit-id: 4707b2df138c81c69c09dae73ab0f16c429336de Former-commit-id: 8fdd5a268b3fb3150b8ac9b50e9c507c2bc2c07e --- docs/zh/sys-ajax/README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/zh/sys-ajax/README.md b/docs/zh/sys-ajax/README.md index cda140514..6ea7e7698 100644 --- a/docs/zh/sys-ajax/README.md +++ b/docs/zh/sys-ajax/README.md @@ -106,9 +106,6 @@ VUE_APP_API=/api-dev/ service.interceptors.response.use( response => { // 成功返回数据,在这里判断和后台约定的状态标识 - }, - error => { - // 发生 http 错误,在这里判断状态码 } ) ``` @@ -117,6 +114,15 @@ service.interceptors.response.use( 如果需要针对某个 http 错误指定处理方法,应该在响应拦截器中第二个参数中添加对应的代码。 +``` js +service.interceptors.response.use( + response => {}, + error => { + // 发生 http 错误,在这里判断状态码 + } +) +``` + ### 不返回 code 在默认的设置中,如果您的接口没有返回 code 字段,将不会进行状态(非 http 状态,而是和后台约定好的状态类型)判断,直接返回 axios 请求返回的数据。