From the course: Learning Vue.js

Unlock the full course today

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

Conditional rendering with v-if

Conditional rendering with v-if - Vue.js Tutorial

From the course: Learning Vue.js

Start my 1-month free trial

Conditional rendering with v-if

- [Instructor] In this video, we'll turn our attention back to our flashcard presenter and clean up our template using some additional directives for conditionally displaying elements. If we look at this first inner div here inside the div that our app is mounted on, we have this click handler here and for the value of that directive we have a bit of JavaScript code that will be executed when a user clicks. And that's instead of perhaps a method call to handle the click event. Again, some Vue developers would prefer not to have any statements like this in their templates. Personally, I think a simple assignment like this is okay, but that's about as far as I would go with actually including imperative code in your template. And moving inside where we display either the front or the back of the card in the level two heading or div element here, depending on the value of flipped, this is definitely more logic than I would…

Contents