[TOC]
## Loading
```
//请求
service.interceptors.request.use(config => {
store.dispatch("loading/setLoading", true);
});
//响应
service.interceptors.response.use(
store.dispatch("loading/setLoading", false);
response => {
return Promise.reject(response);
}
},
error => {
return Promise.reject(error);
}
);
```
## 按钮上使用
```
<a-button
type="primary"
:icon="`${!isEdit ? 'edit' : 'save'}`"
:class="{ disabled: loading }"
@click="save">
{{!isEdit ? "编辑" : "保存"}}
</a-button>
```
## 表格上使用
```
<a-table
bordered
:loading\="loading"
```
## 弹窗使用
```
:ok-button-props ="{ props: { loading: loading } }"
```
## 使用
code判断和错误结果的处理无需处理,已封装在request中
```
sysuserPage(param).then(res => {
const { data } = res;
if (data) {
this.dataSource = data.data || [];
this.page.total = Number(data.total) || 0;
}
});
```
```
//响应
service.interceptors.response.use(
response => {
const data = response.data;
if (data.code === "0000") {
return Promise.resolve(response);
} else {
message.error({
content: h => <div domPropsInnerHTML={response.data.msg || ""}></div>
});
return Promise.reject(response);
}
},
error => {
message.error(err.info || "" + error.response.data.msg);
return Promise.reject(error);
}
);
```