From the course: Learning Vue.js

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Adding modifiers

Adding modifiers - Vue.js Tutorial

From the course: Learning Vue.js

Start my 1-month free trial

Adding modifiers

- [Instructor] View includes several directive modifiers that provide shorthand syntax for adding certain behaviors. For example, if we look at the deck name property in view DevTools, we can see that the bound value increases in length if I just hit the Space bar a few times. We might want to write some code in a submit event handler that trims that string before sending it to the server. But we have a convenient alternative in the trim modifier which is basically as easy as just typing the word trim in our template. So we'll do that right after the V model for deck name. So this becomes V-model.trim. If I go back and refresh, and if you watch deck name now in the view DevTools, you can see that no matter how many times I press the Space bar, the bound value in our data object doesn't change. But of course this only handles leading or trailing white space. So if I start typing out here, I'll get a long string with that…

Contents