function load(url) { let imgObj = new Image(); // 创建图片对象 imgObj.src = url; if (imgObj.complete) { console.log(‘is loaded‘) } else { imgObj.onload = () => { console.log(‘loading success‘) }; imgObj.onerror = () => { console.log(‘loading error‘) } } }
function load(url) { let imgObj = new Image(); // 创建图片对象 imgObj.src = url; if (imgObj.complete) { console.log(‘is loaded‘) } else { imgObj.onload = () => { console.log(‘loading success‘) }; imgObj.onerror = () => { console.log(‘loading error‘) } } }