Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.8k views
in Technique[技术] by (71.8m points)

axios的回调是否有不妥之处

axios({

}).then((response)=>{

}).catch((error)=>{

});

尽管多数文档里给出的回调方式都是如此,但这样的回调并不能像ajax的done()和fail()那样将错误信息区分开来
最近在弄一个react项目,用的antd组件,在使用antd的checkbox多选框功能时忽略了initialValues无法实时动态更新数据,导致就算参数请求返回的错误内容也会执行then()里的内容
而我想知道是的axios的回调能否有想ajax的done()和fail()这样的回调方式


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

使用拦截器
定义一个错误处理


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...