Solution 要做什麼
對照完整答案、責任邊界與原因。
本主題檔案:files/main.js
定位:把 counter 寫在 getter 與 method 內,不要只數讀取端。
Solution · code-edit
對照完整答案、責任邊界與原因。
對照完整答案、責任邊界與原因。
本主題檔案:files/main.js
定位:把 counter 寫在 getter 與 method 內,不要只數讀取端。
頁面不會替你修改檔案;請在實作檔完成後重新整理確認。
count=2,兩種執行計數為0。
computedRuns=1、methodRuns=2、computedValue=4、methodValue=4。
const doubled=computed(()=>{runs++;return count.value*2}); const calculate=()=>{calls++;return count.value*2}。只在本階段資料夾內操作,避免改到其他章節。
index.htmlstyle.cssmain.js證據:computedRuns=1、methodRuns=2、兩者值皆4
回到主題說明