Vue.js — The Progressive JavaScript Framework
Vue.js is a progressive framework for building user interfaces. It features an approachable core with an incrementally adoptable ecosystem — from simple script includes to full-featured SPA development with Composition API, reactivity, and single-file components.
先审查再安装
这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。
npx -y tokrepo@latest install 6935d236-3702-11f1-9bc6-00163e2b0d79 --target codex先 dry-run,确认写入项后再运行此命令。
What it is
Vue.js is a progressive JavaScript framework for building user interfaces. It provides a reactive data binding system, component architecture, and a rich ecosystem including Vue Router for navigation and Pinia for state management. Vue can be used as a lightweight library for enhancing static pages or as a full framework for single-page applications.
Vue targets frontend developers at all skill levels. Its gentle learning curve makes it accessible to beginners, while its Composition API and TypeScript support satisfy the needs of large-scale application development.
How it saves time or tokens
Vue's single-file component format (.vue files) co-locates template, script, and style in one file, reducing context switching during development. The Composition API enables logic reuse through composable functions, eliminating the need to restructure components when sharing behavior.
The Vue CLI and Vite-based scaffolding tool (create-vue) set up a production-ready project with routing, state management, and build optimization in a single command. This eliminates hours of boilerplate configuration.
How to use
- Create a new Vue project:
npm create vue@latest my-app
cd my-app
npm install
npm run dev
- Edit
src/App.vueto build your interface:
<script setup>
import { ref } from 'vue'
const count = ref(0)
</script>
<template>
<button @click="count++">Count: {{ count }}</button>
</template>
- Build for production:
npm run build
Example
<script setup lang="ts">
import { ref, computed } from 'vue'
interface Todo {
id: number
text: string
done: boolean
}
const todos = ref<Todo[]>([
{ id: 1, text: 'Learn Vue 3', done: false },
{ id: 2, text: 'Build an app', done: false }
])
const remaining = computed(() =>
todos.value.filter(t => !t.done).length
)
function toggle(todo: Todo) {
todo.done = !todo.done
}
</script>
<template>
<h2>Todos ({{ remaining }} remaining)</h2>
<ul>
<li v-for="todo in todos" :key="todo.id">
<input type="checkbox" :checked="todo.done" @change="toggle(todo)" />
{{ todo.text }}
</li>
</ul>
</template>
This demonstrates Vue's reactivity system, computed properties, list rendering, and TypeScript integration in a single-file component.
Related on TokRepo
- AI coding tools -- Explore tools that enhance frontend development workflows
- Featured workflows -- Discover other popular frameworks and libraries
Common pitfalls
- Mixing Options API and Composition API in the same project creates inconsistency. Pick one style and apply it consistently. The Composition API with
<script setup>is the recommended approach for new projects. - Vue's reactivity system tracks property access. Destructuring reactive objects loses reactivity. Use
toRefs()when destructuring props or store state. - Large Vue applications need code splitting. Without lazy-loaded routes (
defineAsyncComponentand dynamic imports), the initial bundle grows large and slows page load.
常见问题
Vue 3 introduced the Composition API, improved reactivity with Proxy-based tracking, better TypeScript support, Teleport and Suspense components, and significant performance improvements. Vue 2 reached end of life in December 2023. New projects should use Vue 3.
Vue uses single-file components with templates by default, while React uses JSX. Vue provides built-in reactivity, transitions, and a router as official packages. React's ecosystem relies more on third-party libraries. Vue has a gentler learning curve; React has a larger ecosystem and job market.
Yes. Nuxt is the official Vue framework for SSR. It provides file-based routing, auto-imports, SEO optimization, and hybrid rendering modes. For basic SSR without Nuxt, Vue provides the @vue/server-renderer package.
Yes. Vue 3 is written in TypeScript and provides first-class TypeScript support. The Composition API with <script setup lang='ts'> enables full type inference for props, events, slots, and composables. Volar is the recommended VS Code extension for Vue TypeScript support.
Pinia is the officially recommended state management library for Vue 3. It replaced Vuex as the default choice. Pinia provides a simpler API, better TypeScript support, and devtools integration. For simple applications, Vue's built-in reactivity with provide/inject may be sufficient.
引用来源 (3)
- Vue.js Official Site— Vue.js is a progressive framework for building user interfaces
- Vue.js GitHub— Composition API and single-file components
- Pinia Documentation— Pinia is the recommended state management library
讨论
相关资产
NestJS — Progressive Node.js Framework for Enterprise Apps
NestJS is a progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript. It uses modular architecture inspired by Angular and supports Express/Fastify underneath.
Quasar Framework — Vue.js Components for Web, Mobile, Desktop, and Electron
A high-performance Vue.js framework with 70+ components that can target SPAs, SSR, PWAs, mobile apps via Capacitor/Cordova, desktop via Electron, and browser extensions from one codebase.
Next.js — The Full-Stack React Framework for the Web
Next.js is the most popular React framework for building full-stack web applications. It provides server-side rendering, static generation, API routes, file-based routing, and React Server Components — making React production-ready out of the box.
Moleculer — Progressive Microservices Framework for Node.js
Build scalable microservices with built-in service discovery, load balancing, and fault tolerance. Moleculer provides a convention-driven framework for Node.js that handles inter-service communication, caching, and event-driven architecture out of the box.