// 对 xhr.send 再包多一层
var originSend = XMLHttpRequest.prototype.send
XMLHttpRequest.prototype.send = function () {var args = argumentsvar self = this//var token = localStorage.getItem('token')// 假如把 token 放在请求头里self.setRequestHeader('token', "122333")console.log('后续请求token: ', "1111111")originSend.apply(self, args)}
只要是前端用XMLHttpRequest这个对象发请求的都会携带token