vue-options-api-best-practices
vuejs-ai/skills
提供 Vue 3 Options API 的最佳實踐、TypeScript 整合技巧,以及常見陷阱的解決方案。
...展開全部Vue.js 選項 API 的最佳實務、TypeScript 整合以及常見陷阱。
TypeScript
- 需為元件屬性啟用 TypeScript 類型推斷 → 請參閱 ts-options-api-use-defineComponent
- 在此情境下為 Options API 啟用類型安全性 → 請參閱 ts-strict-mode-options-api
- 在搭配 prop 驗證器時使用舊版 TypeScript → 參閱 ts-options-api-arrow-functions-validators
- 事件處理函式參數需要適當的型別安全性 → 參閱 ts-options-api-type-event-handlers
- 需要使用介面為物件或陣列屬性指定類型 → 請參閱 ts-options-api-proptype-complex-types
- 注入的屬性完全缺少 TypeScript 類型 → 請參閱 ts-options-api-provide-inject-limitations
- 複雜的計算屬性缺乏明確的類型文件 → 參見 ts-options-api-computed-return-types
方法與生命週期
- 方法未綁定至元件實例上下文 → 參見 no-arrow-functions-in-methods
- 生命週期鉤子無法存取元件資料 → 參閱 no-arrow-functions-in-lifecycle-hooks
- 防抖函式在不同元件實例間共享狀態 → 參閱 stateful-methods-lifecycle
---
name: vue-options-api-best-practices
description: Provides Vue 3 Options API best practices, TypeScript integration tips, and solutions to common gotchas.
license: MIT
---
Vue.js Options API best practices, TypeScript integration, and common gotchas.
### TypeScript
- Need to enable TypeScript type inference for component properties → See [ts-options-api-use-definecomponent](reference/ts-options-api-use-definecomponent.md)
- Enabling type safety for Options API this context → See [ts-strict-mode-options-api](reference/ts-strict-mode-options-api.md)
- Using old TypeScript versions with prop validators → See [ts-options-api-arrow-functions-validators](reference/ts-options-api-arrow-functions-validators.md)
- Event handler parameters need proper type safety → See [ts-options-api-type-event-handlers](reference/ts-options-api-type-event-handlers.md)
- Need to type object or array props with interfaces → See [ts-options-api-proptype-complex-types](reference/ts-options-api-proptype-complex-types.md)
- Injected properties missing TypeScript types completely → See [ts-options-api-provide-inject-limitations](reference/ts-options-api-provide-inject-limitations.md)
- Complex computed properties lack clear type documentation → See [ts-options-api-computed-return-types](reference/ts-options-api-computed-return-types.md)
### Methods & Lifecycle
- Methods aren't binding to component instance context → See [no-arrow-functions-in-methods](reference/no-arrow-functions-in-methods.md)
- Lifecycle hooks losing access to component data → See [no-arrow-functions-in-lifecycle-hooks](reference/no-arrow-functions-in-lifecycle-hooks.md)
- Debounced functions sharing state across component instances → See [stateful-methods-lifecycle](reference/stateful-methods-lifecycle.md)
所有檔案
11 個檔案安裝 vue-options-api-best-practices
請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。
下載 ZIP複製儲存庫並將技能檔案複製到您的專案中。
git clone https://github.com/vuejs-ai/skills/tree/main/skills/vue-options-api-best-practices # Copy SKILL.md to your .claude/skills/ directory
複製





首頁
