Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Computed Properties | Section
Практика
Проекти
Вікторини та виклики
Вікторини
Виклики
/
Vue.js Fundamentals and App Development

bookComputed Properties

Свайпніть щоб показати меню

Computed properties allow you to create values based on other reactive data. They automatically update when the data they depend on changes.

To create a computed property, use the computed() function.

<script setup>
import { ref, computed } from "vue";

const firstName = ref("John");
const lastName = ref("Smith");

const fullName = computed(() => {
  return firstName.value + " " + lastName.value;
});
</script>

<template>
  <p>{{ fullName }}</p>
</template>

The fullName value is calculated from firstName and lastName. When either value changes, the computed property updates automatically.

Computed properties help you keep logic clean and avoid repeating calculations in the template.

question mark

What is the purpose of a computed property in Vue?

Виберіть правильну відповідь

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 14

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Секція 1. Розділ 14
some-alt