Courses Blog About
⬅️ Back to the course

What is it Vue.js ?

introduction

Vue.js is a progressive JavaScript framework for creating user interfaces. It combines:

Key Features:

Installation Vue.js

Method 1: CDN (Quick Start)

Suitable for simple projects or learning the basics. Add to HTML:

<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>

Method 2: White (recommended for development)

Creating a project via the command line:

npm create vue@latest
# or
yarn create vue

Select the settings (Vue Router and Pinia are enough to start with)

Then run the project:

cd ваш-проект
npm install
npm run dev

Open up http://localhost:5173 — Your app is ready

The first Vue app

Option 1: Via CDN

<!DOCTYPE html>
<html lang="ru">
<head>
  <meta charset="UTF-8">
  <title>My First Vue app</title>
  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
  <div id="app">
    <h1>{{ message }}</h1>
    <button @click="reverseMessage">Flip the text</button>
  </div>

  <script>
    const { createApp } = Vue;

    createApp({
      data() {
        return {
          message: 'Hello, Vue!'
        }
      },
      methods: {
        reverseMessage() {
          this.message = this.message.split('').reverse().join('');
        }
      }
    }).mount('#app');
  </script>
</body>
</html>

Code analysis

Option 2: Via Vite (Composition API)

<template>
  <div>
    <h1>{{ message }}</h1>
    <button @click="reverseMessage">Flip the text</button>
  </div>
</template>

<script setup>
import { ref } from 'vue';

const message = ref('Привет, Vue!');

const reverseMessage = () => {
  message.value = message.value.split('').reverse().join('');
};
</script>

<style scoped>
button {
  padding: 8px 16px;
  background: #42b983;
  color: white;
  border: none;
  border-radius: 4px;
}
</style>

It is recommended to use the composition api

Code analysis

Conclusion

You found out:

Homework:

  1. Add a new button that capitalizes the text.
  2. Change the button color via v-bind:style
frontline

FrontLine

Join us in telegram

Other interesting posts in a convenient format

Subscribe

Another lessons