heuulzp / vue-axios Goto Github PK
View Code? Open in Web Editor NEW封装axios
Home Page: http://www.jianshu.com/p/3ab216fa185c
License: MIT License
封装axios
Home Page: http://www.jianshu.com/p/3ab216fa185c
License: MIT License
getData(){
this.$axios.get("/h5/grammar/study/v3.0.0/list", {student_grunit_id: 1}, (data)=>{
HT.log("【"+this.$options.name+"】", data)
});
},
【http.js】
function checkCode (res, callback) {
// 如果code异常(这里已经包括网络错误,服务器错误,后端抛出的错误),可以弹出一个错误提示,告诉用户
if (res.status === -404) {
alert(res.msg)
}
if (res.data && (res.data.errcode != "200")) {
alert(res.data.errmsg) ### //只提示错误,不执行操作
}
if (res.data && (res.data.errcode == "200")) {
callback(res.data) //成功并执行回调函数
}
}
老铁,这最后错误抛出的封装为什么用then,不用catch啊
默认支持get和post,那其他的put、delete之类的是否要封装新的方法?
Maximum call stack size exceeded
写了两个then ,第二个应该是catch 把
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.