404 Not Found

404 Not Found


nginx

Vue.js Introduction

Vue.js is a progressive JavaScript framework for building user interfaces—it allows you to efficiently develop web applications using a declarative, component-based approach, ranging from simple forms to complex enterprise-level SPAs.

This tutorial is designed for beginners with a basic understanding of HTML, CSS, and JavaScript. It starts with the core concepts of Vue 3 and progresses until you can independently develop a complete, medium-sized e-commerce back-end system. The learning curve differs from that of W3Schools and Newbie Tutorial—we take a Vue 3 + Composition API-first approach, using a real-world e-commerce project (a SaaS back-end with 5,000 merchants and 30,000 SKUs) as a practical exercise.

1. What You'll Learn


2. The Story of a SaaS Team’s Front-End Technology Selection

(1) Pain Point: Five Frameworks—Which One Should You Choose?

A fast-growing SaaS company with 200,000 lines of front-end code, the tech lead Alice faces a tough decision in Q1 2026:

The product manager Charlie adds pressure:

"We have 30,000 SKUs in our admin dashboard. Filtering takes 8 seconds on the current React app. New developers take 3 weeks to ship their first feature. We need a 5x improvement in both — by Q3 2026."

(2) The Solution in Vue 3

After 4 weeks of evaluation, Alice chose Vue 3. Here's why:

TEXT
Bundle size:     850KB → 280KB    (-67%)
Initial load:    3.2s  → 0.9s    (-72%)
Onboarding time: 3 weeks → 1 week (-67%)
Job market:      growing 35% YoY

Vue's "progressive" nature means Alice can adopt it incrementally:

  1. Week 1: Replace 1 page with Vue 3 (CDN script tag, no build step)
  2. Week 4: Migrate 10 pages to Single File Components
  3. Week 12: Full SPA with Router + Pinia
  4. Week 24: 200,000 lines migrated, zero downtime

(3) Revenue

After 6 months with Vue 3, the team measured:


3. What is Vue?

Vue (pronounced /vjuː/, similar to "view") is a progressive JavaScript framework for building user interfaces. It was created by Evan You in 2014 and is currently maintained by the Vue.js core team and the global community.

(1) Core Definitions + Vue 3 Architecture Diagram

100%
graph TB
    subgraph Vue3Ecology
        V[Vue 3 Core<br/>@vue/runtime-core]
        R[Vue Router 4<br/>Route Managinent]
        P[Pinia<br/>State Managinent]
        S[SSR/SSG<br/>Nuxt 3]
        T[Vite<br/>Build Tools]
        U[UI Component Library<br/>Element Plus/Naive UI]
    end
    
    V --> R
    V --> P
    V --> S
    T --> V
    U --> V
    
    style V fill:#42b883,color:#fff
    style R fill:#35495e,color:#fff
    style P fill:#ffd02f
    style S fill:#00dc82
    style T fill:#646cff,color:#fff

(2) Five Key Features

Feature Meaning Comparison
Progressive Frameworks Can be adopted as needed, ranging from lightweight libraries to full-fledged frameworks React requires JSX; Angular offers a full suite of tools
Reactive Data The UI updates automatically as data changes, without the need to manually manipulate the DOM jQuery requires manual $(sel).text()
Component-based UI broken down into independent, reusable components; Single-File Components (SFC) HTML tags are not reusable; components can be combined
Declarative Rendering Describes "what it should look like," rather than "how to make it look that way" Imperative DOM Manipulation
Flat learning curve Basic knowledge of HTML/CSS/JS is all you need to get started; TS can be learned gradually For Angular, you’ll need to learn decorators and DI first

(3) Use Cases for Vue

Scenario Suitability Description
Small and Medium-Sized SPA (E-commerce/CRM/Admin) ⭐⭐⭐⭐⭐ Ideal Use Case, Mainstream Vue Usage
Enterprise Applications ⭐⭐⭐⭐ Requires Nuxt 3 + Micro-Frontend Architecture
Mobile H5 ⭐⭐⭐⭐ uni-app / Vant framework
Desktop App ⭐⭐⭐ Electron + Vue (Moderate Solution)
Static Blog ⭐⭐ Astro / Nuxt Content is a better fit
Embedded widget ⭐⭐⭐⭐⭐ Extremely small file size, loaded directly from CDN

4. Vue 3 vs. Vue 2: Key Differences

(1) Overview of Major Improvements

Dimension Vue 2 Vue 3 Impact
Reactive Systems Object.defineProperty Proxy Improved performance, supports arrays/Maps/Sets
API Style Options API-centric Composition API-first More flexible logic reuse
TypeScript Requires manual configuration First-class support Type inference ↑
Package Size ~33KB ~20KB (gzipped) Load ↑
Rendering Speed 1x 1.2–2x Performance ↑
Tree-shaking Not supported Fully supported Unused code is not bundled
Fragment Single-root Multi-root nodes More flexible templates
Teleport None Built-in Simplified modal/drawer implementation
Suspense None Built-in Graceful handling of asynchronous components
TEXT
✅ Vue 3 is the current major version (2020-09 Published, 2026 Stable 5+ years)
✅ Vue 2 As of 2023-12 EOL(End of Life),No longer maintained
✅ 90% New Project,100% The new ecosystem tools are all based on Vue 3
✅ Composition API is the Moofrn Writemg Style Recommenofd by the Vue Team
✅ TypeScript Significant Improvinent in Support,Team Code Quality ↑

❌ Vue 2 This is only necessary when maintaining legacy projects.
❌ Not studying Vue 3 = Misifd Vue Ecology 95% Moofrn tools

5. Composition API vs Options API

(1) Comparison of Two API Styles

Aspect Options API Composition API
Writemg Style data / methods / computed sections setup() Function Collection
Logic Reuse mixins (not recommended) Composables (recommended)
Type Inference General Excellent (designed specifically for TS)
Code Organization Grouped by option type Grouped by business logic
Learning Curve Gentle (beginner-friendly) Slightly steep (requires understanding of ref/reactive)
Suitable for Small to medium Medium to large (recommended for all sizes)

(2) Options API Examples

JS
// Options API - Group by option
export default {
  data() {
    return { count: 0, name: 'Alice' }
  },
  computed: {
    doubleCount() {
      return this.count * 2
    }
  },
  methods: {
    increment() {
      this.count++
    }
  },
  mounted() {
    console.log('Component mounted')
  }
}

(3) Composition API Example

JS
// Composition API - Logical Blocking
import { ref, computed, onMounted } from 'vue'

export default {
  setup() {
    const count = ref(0)
    const name = ref('Alice')
    
    const doubleCount = computed(() => count.value * 2)
    
    function increment() {
      count.value++
    }
    
    onMounted(() => {
      console.log('Component mounted')
    })
    
    return { count, name, doubleCount, increment }
  }
}

(4) Which one should I choose?

Suggestions Scenarios
Use the Composition API for New Projects The Preferred Choice for Vue 3 Projects
Maintaining Legacy Projects Preserving the Options API (Without Breaking Existing Code)
Many new team members The Composition API is actually easier to learn (no "this" confusion)
Complex Business Logic Composition API (Organizes code by business logic for greater clarity)

6. The Vue 3 Ecosystem

Vue 3 is not just a framework, but a complete front-end development ecosystem.

(1) Ecosystem Components Diagram

100%
graph LR
    subgraph Core
        V[Vue 3 Core]
    end
    
    subgraph Official Recommendation
        R[Vue Router 4]
        P[Pinia]
        T[Vite]
    end
    
    subgraph Community Ecosystem
        E[Element Plus]
        N[Naive UI]
        U[UnoCSS]
        I[Vue I18n]
    end
    
    V --> R
    V --> P
    V --> T
    V --> E
    V --> N
    V --> U
    V --> I
    
    style V fill:#42b883,color:#fff

(2) Quick Reference Chart for Key Tools

Tools Roles Must-Learn? Official Website
Vue 3 Core The framework itself ✅ Must-learn vuejs.org
Vite Build tool, 5x faster ✅ Must-learn vitejs.dev
Vue Router 4 Routing Management (Essential for SPAs) ✅ Must-Learn router.vuejs.org
Pinia State Management (Vuex Alternative) ✅ Must-Learn pinia.vuejs.org
Element Plus Desktop UI Library Optional element-plus.org
Naive UI Desktop UI library Optional naiveui.com
Vue I18n Internationalization Optional vue-i18n.intlify.dev
Nuxt 3 SSR/SSG framework Optional nuxt.com
VueUse Practical Composable Library Optional vueuse.org

(3) Comprehensive Learning Path

TEXT
Stage 1(This Tutorial Phase 1-3):Vue 3 Core + Composition API
Stage 2 (This Tutorial Phase 4): Vue Router + Pinia + Advanced API
Stage 3(This Tutorial Phase 5):Vite + Real Projects + Deployment
Advanced (Recommenofd Next Steps): Nuxt 3 SSR / Vitest Test / Performance Optimization

7. Complete Example: Your First Vue 3 Application

▶ Example: Hello Vue 3 Counter (SFC—Single-File Component)

Output:

TEXT
Browser renders: "Hello Vue 3! Welcome, Alice!" heading, click counter showing 0, a green "Click me" button, and "By Alice, 2026" at the bottom.
HTML
<!-- App.vue - First Vue 3 Applications -->
<template>
  <div class="hello-vue">
    <h1>{{ greeting }}</h1>
    <p>You clicked the button <strong>{{ count }}</strong> times.</p>
    <button @click="increment">Click me</button>
    <p class="author">By {{ author }}, {{ currentYear }}</p>
  </div>
</template>

<script setup>
// Composition API + <script setup> Syntax sugar
import { ref, computed } from 'vue'

const count = ref(0)
const author = ref('Alice')

// Computed Properties:Automatic Depenofncy Tracking
const currentYear = computed(() => new Date().getFullYear())
const greeting = computed(() => `Hello Vue 3! Welcome, ${author.value}!`)

// Methods
function increment() {
  count.value++
}
</script>

<style scoped>
.hello-vue {
  text-align: center;
  padding: 2rem;
  font-family: system-ui, sans-serif;
}
button {
  background: #42b883;
  color: white;
  border: none;
  padding: 0.5rem 1.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}
button:hover {
  background: #35495e;
}
.author {
  color: #666;
  font-size: 0.9rem;
  margin-top: 2rem;
}
</style>

Output:

TEXT
Renders: Computed property value derived reactively from source data.

Output (after clicking the button):

TEXT
Hello Vue 3! Welcome, Alice!

You clicked the button 5 times.

[Click me]

By Alice, 2026

▶ Example: How to Integrate a CDN (Up and Running in 5 Lines of HTML)

Output:

TEXT
Browser renders: "Hello Vue 3!" heading, a button labeled "Clicked 0 times". Each click increments the counter.
HTML
<!DOCTYPE html>
<html>
<head><title>Vue 3 Hello</title></head>
<body>
  <div id="app">
    <h1>{{ message }}</h1>
    <button @click="count++">Clicked {{ count }} times</button>
  </div>
  
  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  <script>
    const { createApp, ref } = Vue
    createApp({
      setup() {
        return {
          message: ref('Hello Vue 3!'),
          count: ref(0)
        }
      }
    }).mount('#app')
  </script>
</body>
</html>

Output:

TEXT
Browser renders: "Hello Vue 3!" heading, a button labeled "Clicked 0 times". Each click increments the counter.

Output: Open the HTML file; the page displays "Hello Vue 3!" and a button. Clicking the button increments the number by 1.

▶ Example: "Hello World" runs successfully in 5 minutes

BASH
# 1. Create a Project(Uif create-vue Official Scaffolding)
npm create vue@latest my-vue-app
# Select: TypeScript? No, JSX? No, Router? No, Pinia? No, Vitest? No, E2E? No
cd my-vue-app
npm install

# 2. Start the development server
npm run dev
# → Local: http://localhost:5173/

# 3. Open in a browser,See Vue Default Welcome Page

Output:

TEXT
npm command completed.
Packages installed.
Dev server running at http://localhost:3000

▶ Example: Progress Tracking Chart (5 minutes/30 minutes/1 hour)

Output:

TEXT
See code above for details.
Phase Time Completion Criteria
Get "Hello World" Working 5 Minutes See the Vue default page in your browser
Change 1 line of code 10 minutes Change the value of the App.vue variable to message
Add 1 responsive data point 20 minutes Add ref variable + template display
Add 1 interaction 30 minutes Add @click event + counter
Deploy to Vercel 1 hour Public URL accessible

▶ Example: 5 Common Pitfalls (Avoid Them in 5 Minutes)

Output:

TEXT
npm completed.
Packages installed.
Dev server: http://localhost:3000
Pitfalls Symptoms Solutions
"Forget" .value count++ does not work "ref" requires count.value++ in JS
Automatic template unpacking .value is not needed in the template {{ count }} is sufficient
Object response lost obj.name = 'x' Not responding Wrap with reactive()
Direct array assignment arr[0] = 'x' does not respond Use splice or push
Asynchronous data loss setTimeout assignments not responding Handled internally by ref/reactive

❓ FAQ

Q Which should I choose, Vue 3 or React?
A Choose the one you can stick with until you’ve mastered it. Both can handle 95% of tasks. Vue has a gentler learning curve and a template syntax closer to HTML; beginners can get up to speed in two weeks. React has a larger ecosystem, but you’ll need to get used to the JSX mental model. In terms of job prospects, there’s high demand for both.
Q Do I have to learn TypeScript to use Vue 3?
A No, it’s not required. Vue 3 fully supports plain JavaScript. However, if you plan to work on enterprise-level projects, we strongly recommend learning TypeScript—using TypeScript with Vue 3’s Composition API is considered best practice, and type inference can reduce bugs by 50%.
Q Is the Vue 3 Composition API hard to learn?
A It’s slightly harder than the Options API (since you need to understand concepts like refs and reactivity), but it’s more powerful once you’ve mastered it. I recommend starting with the Options API to get the basics down, then moving on to the Composition API to take your skills to the next level.
Q Is Vue 3 suitable for building mobile apps?
A It can be used for H5 (using the uni-app framework), but for native apps, we still recommend Flutter or React Native. Vue 3’s strength lies in the web (desktop and H5); mobile is a secondary option.
Q Will I be able to find a job in Vue after completing this tutorial?
A Yes. This tutorial covers Vue 3 + Router + Pinia + Element Plus + Vite + TypeScript, which meet the requirements for 90% of Vue job openings. You can learn the remaining project experience and algorithm problems on the job.
Q Can Vue 2 projects still be maintained?
A They can be maintained, but they will no longer receive updates. Vue 2 reached its end-of-life (EOL) in December 2023; all new projects should use Vue 3. If you are maintaining an existing project, we recommend planning a migration to Vue 3.

📖 Summary


📝 Exercises

  1. Basic Questions (Difficulty: ⭐)

    Visit the official documentation at vuejs.org, list the three core features of Vue 3, and explain each feature in one sentence.

  2. Advanced Problems (Difficulty: ⭐⭐)

    Compare Vue 3 and React 18 in the following areas (using a table):

    Dimension Vue 3 React 18
    Bundle size ? ?
    Learning Curve ? ?
    State Management Library ? ?
    Routing Library ? ?
    Domestic Market Share ? ?
  3. Challenge Problem (Difficulty: ⭐⭐⭐)

    Research three real-world projects around you (your own company, a friend’s company, or an open-source project), and take notes:

    1. Which front-end framework did you use?
    2. Why choose this framework?
    3. What would be the cost of switching to Vue 3?

    Write a 300-character research report and post it in the comments section.

Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏