源码如下:
const webRequest = new XMLHttpRequest();
webRequest.onreadystatechange = () => {
if (webRequest.readyState != XMLHttpRequest.DONE) {
return;
}
if (webRequest.status != 200) {
LogUtil.log(LOG_TAG.NORMAL, `status : ${webRequest.status}`);
this.sendNotification(LoginCommandDefine.GetUserInformationResponse);
return;
}
LogUtil.log(LOG_TAG.NORMAL, `response : ${webRequest.responseText}`);
const response = JSON.parse(webRequest.responseText);
this.sendNotification(LoginCommandDefine.GetUserInformationResponse, response);
};
这段代码是 typescript 写的。
请教下 XMLHttpRequest.DONE 这个代码为啥在原生平台上为 undefined,在web平台表现为 4 ?