Starter 要做什麼
先看見缺口,再完成一個小修改。
本主題檔案:files/main.js
定位:先分別記錄 timer 是否觸發、signal.aborted、error.name 與 finally 是否執行。
Starter · code-edit
先看見缺口,再完成一個小修改。
先看見缺口,再完成一個小修改。
本主題檔案:files/main.js
定位:先分別記錄 timer 是否觸發、signal.aborted、error.name 與 finally 是否執行。
頁面不會替你修改檔案;請在實作檔完成後重新整理確認。
status=idle、按鈕可用,模擬工作延遲大於 timeout。
aborted=true、category=timeout、finalState=idle、buttonRestored=true。
const controller=new AbortController(); const timer=setTimeout(()=>controller.abort(), 1000); try { await fetch(url,{signal:controller.signal}); } catch(error) { if(error.name==='AbortError') category='timeout'; } finally { clearTimeout(timer); restore(); }只在本階段資料夾內操作,避免改到其他章節。
index.htmlcontact.htmlstyle.cssmain.js證據:aborted=true、category=timeout、finalState=idle、buttonRestored=true
前往 Checkpoint →