BeginnerCoder

Lesson 11 — Input length counter

v-model plus computed

Combining the two gives live feedback while someone types: v-model keeps the text in a ref, and a computed turns it into something to show — here, how many characters are left out of a limit.

const bio = ref("")
const words = computed(() => bio.value.split(" ").filter(Boolean).length)

Why it matters: tweet-style limits, password strength and "x of y" counters work this way.

Want it another way?
Task

Make left a computed: 20 minus the text length. Typing hello should show "15 characters left".

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.