Shaping the bound value
The value a field hands you is not always the value you want to store. A user leaves spaces around a name; a number field still gives you a string; a search box fires on every keystroke when you only care about the finished word. You could clean each value in a handler, but Vue lets you say how in the template, with a modifier.
A modifier is a dot-suffixed word on v-model:
<input v-model.trim="name" />
<input v-model.number="age" type="number" />
<input v-model.lazy="query" />
.trimremoves leading and trailing whitespace before storing the value..numbercasts the value to a number, soageholds30, not'30'..lazywaits for thechangeevent instead ofinput, so it updates when the field loses focus rather than on every keystroke.
The modifier changes what lands in your ref, not what the user typed. With
.trim, typing spaces around a word still stores the trimmed word.
Your job is to trim the value a field stores in App.vue.
Challenge
The name field keeps the spaces the user types around it. Export an App
component from App.vue that renders a text <input> bound with v-model
and a <p> wrapped in square brackets showing the stored value.
The Test types Vue and expects the paragraph to read [Vue], with the
spaces gone. The starter binds without a modifier, so the spaces survive and the
Test fails.