Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
任超
/
js.CadastralSystem
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
db6f3d57
authored
2020-12-08 15:13:51 +0800
by
杨威
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
取消数据请求的loading
1 parent
09e91025
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
src/plugin/axios/index.js
src/plugin/axios/index.js
View file @
db6f3d5
...
...
@@ -2,7 +2,7 @@ import store from '../../store/index'
import
axios
from
'axios'
import
router
from
'../../router'
import
{
Message
,
MessageBox
}
from
'element-ui'
import
{
Loading
}
from
'element-ui'
;
//
import { Loading } from 'element-ui';
import
{
httpStatus
}
from
'@/api/config'
// 创建一个 axios 实例
...
...
@@ -19,7 +19,7 @@ const service = axios.create({
function
errorLog
()
{
//请求完成关闭loading
// this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
loadingInstance
.
close
();
//
loadingInstance.close();
// });
MessageBox
.
alert
(
'报错了请联系管理员'
,
'消息提示'
,
{
confirmButtonText
:
'确定'
,
...
...
@@ -27,7 +27,7 @@ function errorLog() {
})
}
//定义loading
let
loadingInstance
=
null
//
let loadingInstance = null
// 请求拦截器
service
.
interceptors
.
request
.
use
(
...
...
@@ -37,12 +37,12 @@ service.interceptors.request.use(
// 让每个请求携带token-- ['X-Token']为自定义key 请根据实际情况自行修改
// config.headers['authkey'] = token
//请求发送成功显示loading
loadingInstance
=
Loading
.
service
({
lock
:
true
,
text
:
'Loading'
,
spinner
:
'el-icon-loading'
,
background
:
'rgba(0, 0, 0, 0.5)'
});
//
loadingInstance = Loading.service({
//
lock: true,
//
text: 'Loading',
//
spinner: 'el-icon-loading',
//
background: 'rgba(0, 0, 0, 0.5)'
//
});
return
config
},
error
=>
{
...
...
@@ -59,7 +59,7 @@ service.interceptors.response.use(
const
{
code
}
=
dataAxios
//请求完成关闭loading
// this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
loadingInstance
.
close
();
//
loadingInstance.close();
// });
// 根据 code 进行判断
if
(
code
===
undefined
)
{
...
...
@@ -90,7 +90,7 @@ service.interceptors.response.use(
},
error
=>
{
if
(
error
&&
error
.
response
)
{
loadingInstance
.
close
();
//
loadingInstance.close();
switch
(
error
.
response
.
status
)
{
case
400
:
error
.
message
=
'请求错误'
;
...
...
Please
register
or
sign in
to post a comment