1.控制按钮 disable
接口调用的时候 给按钮加disable 属性
接口调通 关闭disable
2. xhr.abort()
let btn = document.getElementById('btn')
let lastXhr
btn.onclick = function(){
if(lastXhr){
lastXhr.abort()
}
lastXhr = getAuthCode()
}
function getAuthCode(){
let xhr = new XMLHttpRequest()
xhr.onreadystatechange = function(){}
xhr.open('get','http://localhost:3000/get_code')
xhr.send()
return xhr
}