问题描述:想设置请求超时时间
代码块
在vue的src\api\data.js中的具体方法中添加 timeout: 5000,
export const logLogin = info => {
return axios.request({
url: 'cdn-logs/logLogin',
method: 'get',
timeout: 5000,
params: info
})
}
然后在代码中添加
logLogin (info).then(res => {
}).catch(err => {
// 在这里输出超时错误,并进行处理
console.log("err",err)
})
效果展示