🎓 A1Learner
🔍
0 of 50 lessons completed

Reactivity Introduction

Reactivity is the way Vue keeps the page in step with a value. When the value changes, the page shows the new value.

A plain const

This line holds a plain value.

const count = 0

Show the value

This line shows the count value on the page.

<p>Count: {{ count }}</p>

Example

<script setup>
const count = 0
</script>
<template>
  <div>
    <p>Count: {{ count }}</p>
    <p>The page shows the starting value.</p>
  </div>
</template>

Key points

  • Reactivity is the way Vue keeps the page in step with a value.
  • A value is one piece of information in the code.
  • A plain const holds a value that stays the same.
  • A plain const cannot update the page on its own.

In this example, the script block holds a plain const. The const is named count. Its value is 0. The first line shows that value. The second line names the starting value. A plain const does not update the page. The next lessons add a tool that makes a value update the page.

Note

The next lessons add a tool that makes a value update the page.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

What is reactivity in Vue?