跳转到内容

❧ 拦截页面接口响应结果

(function(open) {
// 监听api获取数据
XMLHttpRequest.prototype.open = function () {
this.addEventListener("readystatechange", function () {
// 需要筛选的url
const url = "/api/v1/advanced/changedata/listCustomerClasses";
if (this.responseURL.indexOf(url) >= -1 && this.readyState == 4) {
const resData = JSON.parse(this.responseText);
// 响应JSON结果
console.log(resData);
}
}, false);
open.apply(this, arguments);
};
)(XMLHttpRequest.prototype.open);