方法一:直接在定义接口时添加timeout: 6000
export function getLogList(params) {
return request({
url: getUrl('list'),
method: 'get',
timeout: 100000, // 接口响应超时时间
params
})
}
方法二:
import axios from 'axios'
import {BASE_URL} from '@/utils/request'
methods: {
getList() {
const instance = axios.create({
timeout: 100000, // 接口响应超时时间
})
instance.get(`${BASE_URL}/system/list`).then(response => {
console.log('接口成功时的回调')
}).catch(() => {})
}
}