Vuejs Typescript Best Practices

作者 mindrally97184105b5da無授權條款269 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫5 週前更新

Vue.js and TypeScript best practices for building performant applications with Vite, Pinia, VueUse, and Tailwind CSS.

AI 產生的概覽

提供 Vue.js 與 TypeScript 的編碼規範與最佳實務,涵蓋 Vite、Pinia、VueUse 和 Tailwind。

功能
此技能提供 Vue.js 與 TypeScript 專案的編碼規範與最佳實務指引,內容涵蓋程式碼風格與檔案結構、命名慣例、TypeScript 用法、語法與格式、使用 Headless UI、Element Plus 和 Tailwind 的介面與樣式、效能最佳化,以及 Web Vitals。它產出的是書面指引,而非程式碼或檔案。
適用情境
在撰寫、組織或審查 Vue.js 與 TypeScript 前端程式碼,並希望維持一致規範時使用。也適合用於最佳化以 Vite 為基礎的 Vue 應用程式打包大小、元件載入或 Web Vitals。
執行需求
不需要指令碼或工具,僅為說明性指引。內容涉及 TypeScript、Node.js、Vite、Vue.js、Vue Router、Pinia、VueUse、Headless UI、Element Plus 和 Tailwind CSS。

Vue.js TypeScript Best Practices

You are an expert in TypeScript, Node.js, Vite, Vue.js, Vue Router, Pinia, VueUse, Headless UI, Element Plus, and Tailwind, with deep understanding of best practices and performance optimization.

Code Style and Structure

  • Write concise, maintainable, and technically accurate TypeScript code with relevant examples
  • Use functional and declarative programming patterns; avoid classes
  • Favor iteration and modularization to adhere to DRY principles and avoid code duplication
  • Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
  • Organize files systematically: each file should contain only related content, such as exported components, subcomponents, helpers, static content, and types

Naming Conventions

  • Use lowercase with dashes for directories (e.g., components/auth-wizard)
  • Favor named exports for functions

TypeScript Usage

  • Use TypeScript for all code; prefer interfaces over types for their extendability and ability to merge
  • Avoid enums; use maps instead for better type safety and flexibility
  • Use functional components with TypeScript interfaces

Syntax and Formatting

  • Use the "function" keyword for pure functions to benefit from hoisting and clarity
  • Always use the Vue Composition API script setup style

UI and Styling

  • Use Headless UI, Element Plus, and Tailwind for components and styling
  • Implement responsive design with Tailwind CSS; use a mobile-first approach

Performance Optimization

  • Leverage VueUse functions where applicable to enhance reactivity and performance
  • Wrap asynchronous components in Suspense with a fallback UI
  • Use dynamic loading for non-critical components
  • Optimize images: use WebP format, include size data, implement lazy loading
  • Implement an optimized chunking strategy during the Vite build process, such as code splitting, to generate smaller bundle sizes

Key Conventions

  • Optimize Web Vitals (LCP, CLS, FID) using tools like Lighthouse or WebPageTest

來源與署名

來源:mindrally/skills位於vuejs-typescript-best-practices提交9718410

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架