ရိုးရိုးလေး ရှင်းပြမယ်
Production Project: Task Dashboard ကို ရိုးရိုးလေးနားလည်မယ်
Project ကို TaskForm, TaskList, TaskItem နှင့် FilterBar components အဖြစ်ခွဲပါ။ Tasks ကို Pinia store ထဲသိမ်းပြီး filteredTasks ကို getter ဖြင့်တွက်ပါ။ Router တွင် dashboard နှင့် task detail routes ထည့်ပြီး form accessibility, empty state နှင့် error handling ကိုစစ်ပါ။
Problem → Why → Solution
ပြဿနာ — ဘာကြောင့် ဒီ concept လိုတာလဲ
UI component ထဲတွင် store logic အားလုံးရေးခြင်း
ဖြစ်လေ့ရှိတဲ့အမှား
Keyboard focus နှင့် form label မထည့်ခြင်း
Core Concept — အလုပ်လုပ်ပုံကိုနားလည်မယ်
Components, props, events, computed, custom composable, Router နှင့် Pinia ကိုပေါင်းစပ်ပြီး task dashboard တည်ဆောက်မည်။
- Project requirements
- Components + state + services
- စမ်းသပ်ပြီး UI
Feature ကို component များအဖြစ်ခွဲရန်
အဓိက Syntax / Pattern
// stores/tasks.js
import { defineStore } from 'pinia'
export const useTasksStore = defineStore('tasks', {
state: () => ({ tasks: [], filter: 'all' }),
getters: {
visible: (state) => state.tasks.filter((task) =>
state.filter === 'all' ||
(state.filter === 'done' ? task.done : !task.done)
)
},
actions: {
add(title) {
this.tasks.push({ id: crypto.randomUUID(), title, done: false })
},
toggle(id) {
const task = this.tasks.find((item) => item.id === id)
if (task) task.done = !task.done
}
}
})Components, props, events, computed, custom composable, Router နှင့် Pinia ကိုပေါင်းစပ်ပြီး task dashboard တည်ဆောက်မည်။
Code ကို အဆင့်လိုက်ဖတ်မယ်
- Project requirements
// stores/tasks.jsProject ကို TaskForm, TaskList, TaskItem နှင့် FilterBar components အဖြစ်ခွဲပါ။ Tasks ကို Pinia store ထဲသိမ်းပြီး filteredTasks ကို getter ဖြင့်တွက်ပါ။ Router တွင် dashboard နှင့် task detail routes ထည့်ပြီး form accessibility, empty state နှင့် error handling ကိုစစ်ပါ။
- Components + state + services
actions: {Components, props, events, computed, custom composable, Router နှင့် Pinia ကိုပေါင်းစပ်ပြီး task dashboard တည်ဆောက်မည်။
- စမ်းသပ်ပြီး UI
})Production Project: Task Dashboard ကို example အသေးတစ်ခုနဲ့စပြီး normal, edge နဲ့ failure cases ကိုစစ်ပါ။
- Project requirements
- Components + state + services
- စမ်းသပ်ပြီး UI
Success
Feature ကို component များအဖြစ်ခွဲရန်
Failure
UI component ထဲတွင် store logic အားလုံးရေးခြင်း
ရိုးရိုးလေး ရှင်းပြမယ်
Project ကို TaskForm, TaskList, TaskItem နှင့် FilterBar components အဖြစ်ခွဲပါ။ Tasks ကို Pinia store ထဲသိမ်းပြီး filteredTasks ကို getter ဖြင့်တွက်ပါ။ Router တွင် dashboard နှင့် task detail routes ထည့်ပြီး form accessibility, empty state နှင့် error handling ကိုစစ်ပါ။
// stores/tasks.js
import { defineStore } from 'pinia'
export const useTasksStore = defineStore('tasks', {
state: () => ({ tasks: [], filter: 'all' }),
getters: {
visible: (state) => state.tasks.filter((task) =>
state.filter === 'all' ||
(state.filter === 'done' ? task.done : !task.done)
)
},
actions: {
add(title) {
this.tasks.push({ id: crypto.randomUUID(), title, done: false })
},
toggle(id) {
const task = this.tasks.find((item) => item.id === id)
if (task) task.done = !task.done
}
}
})A filterable task dashboard with persistent component stateလက်တွေ့စမ်းကြည့်ရန်
Task add/toggle/delete, all/open/done filters, detail route နှင့် localStorage persistence ကိုပြီးစီးအောင်တည်ဆောက်ပါ။
Vue Best Practices — Vue.js
Real-world usage
လက်တွေ့ Project မှာ ဘယ်လိုသုံးမလဲ
Production Project: Task Dashboard ကို example အသေးတစ်ခုနဲ့စပြီး normal, edge နဲ့ failure cases ကိုစစ်ပါ။
Mini challenge
ကိုယ်တိုင်တည်ဆောက်ကြည့်ပါ
Task add/toggle/delete, all/open/done filters, detail route နှင့် localStorage persistence ကိုပြီးစီးအောင်တည်ဆောက်ပါ။
- Example ကို copy မလုပ်ဘဲ ပြန်ရေးပါ
- Normal input နဲ့ edge case စမ်းပါ
- Run မလုပ်မီ compiler/output result ကိုခန့်မှန်းပါ
// stores/tasks.js
import { defineStore } from 'pinia'
export const useTasksStore = defineStore('tasks', {
state: () => ({ tasks: [], filter: 'all' }),
getters: {
visible: (state) => state.tasks.filter((task) =>
state.filter === 'all' ||
(state.filter === 'done' ? task.done : !task.done)
)
},
actions: {
add(title) {
this.tasks.push({ id: crypto.randomUUID(), title, done: false })
},
toggle(id) {
const task = this.tasks.find((item) => item.id === id)
if (task) task.done = !task.done
}
}
})ရလဒ်: Feature ကို component များအဖြစ်ခွဲရန်
အရိပ်အမြွက် ကြည့်ရန်
Production Project: Task Dashboard ကို example အသေးတစ်ခုနဲ့စပြီး normal, edge နဲ့ failure cases ကိုစစ်ပါ။
Quick Quiz 1 / 3
Quick Quiz 2 / 3
Quick Quiz 3 / 3
ဒီသင်ခန်းစာမှာ မှတ်ထားရမယ့်အချက်များ
- Project requirements → Components + state + services → စမ်းသပ်ပြီး UI
- Components, props, events, computed, custom composable, Router နှင့် Pinia ကိုပေါင်းစပ်ပြီး task dashboard တည်ဆောက်မည်။
- UI component ထဲတွင် store logic အားလုံးရေးခြင်း
- Production Project: Task Dashboard ကို example အသေးတစ်ခုနဲ့စပြီး normal, edge နဲ့ failure cases ကိုစစ်ပါ။
Vue Best Practices — Vue.js