Vue.js (pronounced view) is a progressive JavaScript framework used to build user interfaces (UIs) and single-page applications (SPAs).

It focuses on the view layer (the part users see) but can easily integrate with other tools or existing projects.

βš™οΈ Why Use Vue.js?

Here’s why developers love Vue:

  1. 🧩 Reactive & Declarative β€” Automatically updates the UI when data changes.
  2. πŸͺΆ Lightweight & Fast β€” Small size but powerful features.
  3. 🧠 Easy to Learn β€” Simple syntax similar to HTML and JavaScript.
  4. πŸ” Two-Way Data Binding β€” Keeps data and UI in sync.
  5. πŸ”Œ Component-Based β€” Reusable and modular structure.
  6. 🧰 Rich Ecosystem β€” Includes Vue Router (for navigation) and Vuex/Pinia (for state management).
πŸš€ How to Add Vue.js to a Web Page
Option 1: Using CDN (for beginners)

You can include Vue directly in an HTML file:

<!DOCTYPE html>
<html>
<head>
  <title>Vue Example</title>
  <script src="https://unpkg.com/vue@3"></script>
</head>
<body>
  <div id="app">
    <h1>{{ message }}</h1>
  </div>

  <script>
    const app = Vue.createApp({
      data() {
        return {
          message: "Hello, Vue!"
        };
      }
    });
    app.mount('#app');
  </script>
</body>
</html>

βœ… Output:
Displays β€œHello, Vue!” on the page.

🧠 Core Concepts
1. The Vue Instance (App)

Every Vue app starts with creating an instance:

const app = Vue.createApp({
  data() {
    return { message: "Hello Vue!" };
  }
});
app.mount("#app");

#app β†’ is the HTML element where Vue takes control.

2. Data Binding

You can display dynamic data with mustache syntax ({{ }}):

<p>{{ message }}</p>

If message = "Hello Vue!", the page shows that text.

3. Directives

Vue uses directives (special attributes that start with v-) to control behavior.

DirectiveExamplePurpose
v-bind<img v-bind:src="imageUrl">Bind attributes
v-if<p v-if="seen">Now you see me!</p>Conditional rendering
v-for<li v-for="item in items">{{ item }}</li>Loop through lists
v-on<button v-on:click="sayHi">Click Me</button>Handle events
v-model<input v-model="name">Two-way binding for forms
4. Methods

You can define custom functions using methods:

const app = Vue.createApp({
  data() {
    return { count: 0 };
  },
  methods: {
    increment() {
      this.count++;
    }
  }
});

HTML:

<div id="app">
  <button @click="increment">Add</button>
  <p>Count: {{ count }}</p>
</div>
5. Computed Properties

Use computed when you need a value that depends on other data.

computed: {
  reversedMessage() {
    return this.message.split('').reverse().join('');
  }
}

This recalculates automatically whenever message changes.

6. Two-Way Data Binding

With v-model, you can bind input fields to Vue data:

<div id="app">
  <input v-model="name" placeholder="Enter your name">
  <p>Hello, {{ name }}!</p>
</div>
🧩 Components (Building Blocks of Vue)

Vue apps are made of components β€” small, reusable UI pieces.

Example:

app.component('hello-world', {
  template: '<h2>Hello from Component!</h2>'
});

Then use it like:

<hello-world></hello-world>
🧰 Summary
ConceptDescription
Framework TypeProgressive JavaScript Framework
Core FeatureReactive data binding
SyntaxHTML-like templates
Key Directivesv-bind, v-if, v-for, v-on, v-model
App CreationVue.createApp({})
Mounting.mount('#app')
ComponentsReusable pieces of UI
πŸ’‘ Example – Simple Counter App
<!DOCTYPE html>
<html>
<head>
  <script src="https://unpkg.com/vue@3"></script>
</head>
<body>
  <div id="app">
    <h2>Counter: {{ count }}</h2>
    <button @click="count++">Increase</button>
    <button @click="count--">Decrease</button>
  </div>

  <script>
    const app = Vue.createApp({
      data() {
        return { count: 0 };
      }
    });
    app.mount('#app');
  </script>
</body>
</html>

2 Comments

  1. bhavani d

    I had a question about [specific issue], and I was hoping you could address it in a future post or update the tutorial with some tips on it?

  2. J Varsha

    Thank you for explaining this so clearly.

Leave a Reply

Your email address will not be published. Required fields are marked *