O'Reilly logo

The Majesty of Vue.js by Kostas Maniatis, Alex Kyriakidis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. A Flavor of Directives

In this chapter we are going through some basic examples of Vue's directives. Well, if you have not used any framework like Vue.js or AngularJS before, you probably don't know what a directive is. Essentially, a directive is some special token in the markup that tells the library to do something to a DOM element. In Vue.js, the concept of directive is drastically simpler than that in Angular. Some of the directives are:

  • v-show which is used to conditionally display an element
  • v-if which can be used instead of v-show
  • v-else which displays an element when v-if or v-show evaluates to false

Also, there is v-for, which requires a special syntax and its use is for rendering (for example, render a list of items based on ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required