二次封装axios时刻意服务端模拟了延迟返回数据的场景,用return Promise.reject(error) 返回异常,报如下错误,
[Vue warn]: Error in v-on handler (Promise/async): "Error: timeout of 5000ms exceeded"
export default class Page1 extends Vue { private async getList() { const {data,pagination} = await getArticles(this.listQuery) console.log('data: ',data) console.log('pagination: ',pagination) } }
解决办法:用 try{} catch(e){} 包裹处理方法
export default class Page1 extends Vue { private async getList() { try { const {data,pagination} = await getArticles(this.listQuery) console.log('data: ',data) console.log('pagination: ',pagination) } catch (e) { console.log(e.message) } } }