标签:ret int url http body bsp amp turn pre
vue2自带的拦截器,已被 axios 替代: https://github.com/mzabriskie/axios
try { Vue.http.interceptors.push(function (request, next) { // ... // 请求发送前的处理逻辑 // ... var getFullUrl = function (url) { if (url.slice(0, 2) == "//") return url; if (url[0] != "/") { url = "/" + url; } return "//172.30.8.132:808" + url; } // request.method = "JSONP"; request.url = getFullUrl(request.url); next(function (response) { if (response.status == 200) { if (response.body && response.body.msg) { this.$message.error(response.body.msg); return new Promise(function (resolve, reject) { reject(response); }); } } else if (response.status == 500) { this.$message.error(response.body); // throw new Error("Error"); return new Promise(function (resolve, reject) { reject(response); }); } return; }) }); } catch (e) { //console.info("Vue.http.interceptors:" + e.message); }
标签:ret int url http body bsp amp turn pre
原文地址:http://www.cnblogs.com/newsea/p/6669589.html