Open alanhe421 opened 4 years ago
var xhr = new XMLHttpRequest(); xhr.open('get', '/hello1.json', true); xhr.onload = function (e) { console.log(xhr); }; xhr.send();
经常使用的Axios实际上是对XHR做了二次封装
open方法的第三个参数支持同步异步设定。假如设定为false即同步,则send后面的逻辑会一直等着收到回复才可以继续执行。
经常使用的Axios实际上是对XHR做了二次封装