vue map 分類原則 - daniel-qa/Vue GitHub Wiki
核心功能決定主分類
| 核心類別 | 判斷重點 | 例子 | 備註 |
|---|---|---|---|
| 1. 語言基礎 | 語法特性、變數宣告、資料型別、物件操作 | let/const/var, obj = {}, arr.push(), 展開運算子 ... |
若只是單純建立物件或陣列,歸在這裡即可 |
| 2. 函式與結構 | 函式、箭頭函式、回呼函式、解構賦值 | const foo = () => {}, arr.map(x => x*2), const {a,b} = obj |
處理資料或事件的邏輯核心 |
| 3. 非同步處理 (API) | 呼叫 API、Promise、async/await、非同步回調 | axios.get(...), this.$api.xxx(), .then(res => ...), await fetch(...) |
核心是 資料請求或非同步操作,UI/Store更新算輔助 |
| 4. 模組化 | import/export、組件匯入、路由設定 | import Foo from './Foo.vue', export default {...} |
主要是檔案/模組結構 |
| 5. 物件導向 & 擴充 | Class、原型、繼承、封裝服務 | class ApiService {...}, Vue composition API 可封裝的邏輯 |
適合封裝可重用邏輯 |
| 6. Vue 特化整合 | 響應式資料、UI更新、事件處理、全局方法 | this.isLoading = true, this.$store.commit(...), this.$Message.success(...) |
若跟非同步結合,用作輔助,不必單獨分類 |