KD's Tech Blog

Hi, 我是 KD Chang 凱迪,我在這書寫我的軟體開發/程式設計技術筆記 | KD 技術部落格

Vue ref 與 reactive 入門教學筆記 | 學習筆記


前言在 Vue 3 中,ref 與 reactive 都是用來創建響應式資料的工具,但它們適用的情境略有不同。以下是清楚的比較與實際使用範例,幫助你理解什麼時候該用哪一個。 ref 使用情境適用於: 原始資料型別:如 Number、String、Boolean、Date 等。 你只需要追蹤單一值。 當你需要某個變數傳遞到 <template> 或函式中。 語法:import ......

Vue pinia 保持 reactive 入門教學筆記 | 學習筆記


保持 reactive 寫法: 1️. 用 computedconst todos = computed(() => todoStore.todos) 優點 保持 reactive 簡單直接 在 template 裡 todos 可以直接使用 缺點 如果只是讀值,其實有點多餘 建議用於:在 template 需要用 v-for="todo in t......