框架內部已經根據公司接口api結構封裝好了請求方法,可以在需要使用的地方直接調用,源碼在src/assets/js/http.js
請求類方法包含兩個公用方法:單個請求和并發請求
> 注意,接口配置在config目錄內配置
<br>
## **單個請求example**
```javascript
async created(){
try {
let result = await this.$http.ajax({
url:'/goodsData',
method:"post",
data:{pms:1},
loading:true
});
console.log('請求成功',result);
}catch (e) {
console.log('請求失敗',e);
return false;
}
}
```
<br>
## **并發請求example**
```javascript
async created(){
try {
let result = await this.$http.all({
requestArr:[
{
url:'/goodsData',
method:"post",
data:{pms:1}
},{
url:"/search",
method:"post",
data:{index:2}
},{
url:"/integral",
method:"post"
}]
});
console.log('請求成功',result);
}catch (e) {
console.log('請求失敗',e);
return false;
}
}
```