Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
JavaScript from Frontend to Backend

You're reading from   JavaScript from Frontend to Backend Learn full stack JavaScript development using the MEVN stack with quick and easy steps

Arrow left icon
Product type Paperback
Published in Jul 2022
Publisher Packt
ISBN-13 9781801070317
Length 336 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Eric Sarrion Eric Sarrion
Author Profile Icon Eric Sarrion
Eric Sarrion
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Part 1: JavaScript Syntax
2. Chapter 1: Exploring the Core Concepts of JavaScript FREE CHAPTER 3. Chapter 2: Exploring the Advanced Concepts of JavaScript 4. Part 2: JavaScript on the Client-Side
5. Chapter 3: Getting Started with Vue.js 6. Chapter 4: Advanced Concepts of Vue.js 7. Chapter 5: Managing a List with Vue.js 8. Part 3: JavaScript on the Server-Side
9. Chapter 6: Creating and Using Node.js Modules 10. Chapter 7: Using Express with Node.js 11. Chapter 8: Using MongoDB with Node.js 12. Chapter 9: Integrating Vue.js with Node.js 13. Other Books You May Enjoy

Using directives

Vue.js improves the writing of HTML code by offering to write its own components, as we have seen in the preceding section. The framework also makes it easier to write basic HTML code by adding new attributes to the HTML elements or to the components created. These new attributes are called directives.

Note

Directives are used exclusively in HTML elements or created components, that is, in the template section of components.

Their name begins with v-, so as not to be confused with other existing HTML attributes. The main directives are v-if, v-else, v-show, v-for, and v-model. They will be explained now.

The v-if and v-else directives

The v-if directive is used to specify a condition. If true, the HTML element (or component) will be inserted into the HTML page. Otherwise, it will not be present.

Let’s use the v-if directive to indicate that we want to display the value of the counter only for values less than or equal to 20. As soon as the...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime