Lesson 73
30 XP

Counter App

Build an Interactive Counter with Increment and Decrement

Step 1 of 5

Understanding Counters

A counter is one of the simplest interactive apps. It stores a number and allows you to increase or decrease it with buttons.

Counter Features:

  • State: Store the current count value
  • Increment: Add to the count
  • Decrement: Subtract from the count
  • Reset: Return to starting value
// Counter State
const count = ref(0)
// Increment Function
const increment = () => {'{'}
count.value++
{'}'}

Simple Counter Demo:

0
Current Count