请求验证码返回二进流前端展示

it2026-03-27  5

async getVerifCode() { var url = "/www......"; var xhr = new XMLHttpRequest(); xhr.open("GET", url, true); xhr.responseType = "blob"; xhr.setRequestHeader("client_type", "DESKTOP_WEB"); xhr.setRequestHeader("desktop_web_access_key", "_desktop_web_access_key"); xhr.onload = function () { if (this.status == 200) { var blob = this.response; var img = document.createElement("img"); img.onload = function (e) { window.URL.revokeObjectURL(img.src); }; img.src = window.URL.createObjectURL(blob); img.title = "看不清?换一张"; $("#imgcontainer").html(img); } }; xhr.send(); },

最新回复(0)