axios 设置超时时间 timeout

全局设置网络超时

axios.defaults.timeout = 30000;

 单独对某个请求设置网络超时

let timeout = parseInt(paramsTimeout);
this.$ajax.post(url, params, {timeout: timeout})
  .then(res => {
    console.log('response='+response);
  })
  .catch(reason => {
    console.log('reason'+reason);
  })
})

参考:

axios 设置超时时间 timeout

https://blog.csdn.net/daipianpian/article/details/90714461

 

posted @ 2020-07-09 16:04  张艳涛&java  阅读(4603)  评论(0编辑  收藏  举报