VueJS Filter Currency Rounding 2 decimal places Example

VueJS Filter Currency Rounding 2 decimal places Example

Today, We want to share with you VueJS Filter Currency Rounding 2 decimal places Example.In this post we will show you VueJS – Input number with 2 decimal places, hear for vue js currency filter and vuejs round to 2 decimal places we will give you demo and example for implement.In this post, we will learn about VueJS 2 Decimal Pipe, Percent Pipe and Currency Pipe Example with an example.

VueJS Filter Currency Rounding 2 decimal places Example

There are the Following The simple About VueJS Filter Currency Rounding 2 decimal places Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop , so the some major files and Directory structures for this example is following below.

  • index.html

VueJS Currency filter with rounding decimal places example

index.html

This is where I will make a simple HTML form and PHP server side source code for our web application. To make the forms simply all souce code copy and write it into your any text editor Like Notepad++, then save file it as index.html.

Read Also:  how to open wordpress dashboard in localhost xampp?

<!DOCTYPE html>
<html>
<head>
  <title>VueJS Filter Currency Rounding 2 decimal places Example</title>
  <script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
</head>
<body>
    <div id="pakaApp">
        Enter Rate:
        <my-currency-filter-input v-model="productRate"></my-currency-filter-input>
        <p>Rate (in parent component): {{ productRate }}</p>
    </div>
</body>
<script>
  Vue.component('my-currency-filter-input', {
      props: ["value"],
      template: `
          <div>
              <input type="text" Placeholder="Enetr Your Rate" v-model="previewValue" @blur="activeInpdata = false" @focus="activeInpdata = true"/>
          </div>`,
      data: function() {
          return {
              activeInpdata: false
          }
      },
      computed: {
          previewValue: {
              get: function() {
                  if (this.activeInpdata) {
                      return this.value.toString()
                  } else {
                      
                      return "$ " + this.value.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")
                  }
              },
              set: function(newVal) {
                  let flagVal = parseFloat(newVal.replace(/[^\d\.]/g, ""))
                  if (isNaN(flagVal)) {
                      flagVal = 0
                  }
                  this.$emit('input', flagVal)
              }
          }
      }
  });
  new Vue({
      el: '#pakaApp',
      data: function() {
          return {
              productRate: 255
          }
      }
  });
</script>
</html>

Angular 6 CRUD Operations Application Tutorials

Read :

Read Also:  Laravel Drop all tables with MySQL

Summary

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

I hope you get an idea about VueJS Filter Currency Rounding 2 decimal places Example.
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.

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

Your email address will not be published. Required fields are marked *