Directives in Vue.js Examples – vue interface

Today, We want to share with you Directives in Vue.js Examples.In this post we will show you Vue.js Directives Tutorial, hear for A simple, real-world Vue.js directive example we will give you demo and example for implement.In this post, we will learn about Creating Custom Directives in Vue.js with an example.

Directives in Vue.js Examples

There are the Following The simple About Directives in Vue.js Examples Full Information With Example and source code.

As I will cover this Post with live Working example to develop vue directive in separate file, so the vue directive event listener for this example is following below.

Also Read :  REST API CRUD Example in PHP with MySQLi

In Vue Templating, We shall search yourself lear to vuejs all utilizing the list of the directives that exist. A simple Vue Directive is a Vue-specific some easy to use attribute prefixed by a v- in vuejs latest javascript frameworkd. Each there are vuejs list of the a different Directives purpose.

There are the following the list of vuejs directives that We can simple use:

  • v-bind
  • v-cloak
  • v-else
  • v-else-if
  • v-for
  • v-html
  • v-if
  • v-model
  • v-on
  • v-once
  • v-pre
  • v-show
  • v-text

Firstof all, let’s we simple vuejs create an array of objects in the main about Product component logic:

  data() {
    return {
      products: [
          { "product": "Vue.js" },
          { "product": "Lenova z570 with Bag free" }
      ]
    }
  },

Next, adjust the template section:

Also Read :  PHP Codeigniter URL Routing Automatically

<template>
  <div class="products">
    <div class="pakainfo-shop">
      <ul>
        <li v-for="(data, index) in products" :key='index'>{{index}}. {{data.product}}</li>
      </ul>
    </div>
  </div>
</template>

and last things, Let’s try simple one more exmaple below : v-if along as well as v-else for an if else main vuejs statement in the data template:

    <div class="pakainfo-shop">
      <ul>
        <li v-for="(data, index) in products" :key='index'>{{index}}. {{data.product}}</li>
      </ul>

      <!-- Add these 2 lines -->
      <p v-if="products.length >= 1">You have more than 1 product</p>
      <p v-else>You have less than or equal to 1 product</p>

    </div>

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Directives in Vue.js Examples.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Reply

avatar
  Subscribe  
Notify of