Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
how do i remove the decimal point using vuejs

I generate a random number when the model is mounted. I want to remove the "0." The 0. and decimal. I tried adding Math.round() but that gives me a NaN. Can someone tell me what I am missing.

new Vue({
el: '#app',
  
  data: { 
      mixNumber:''
  },
  mounted: function(){
  this.myFunction();
  },
  
   methods:{
    myFunction: function () {       
        this.mixNumber = Math.random();
    this.roundNumber=Math.round();
    }   
   }

});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">

 My ID is: {{mixNumber}}
 
</div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use the following code:

new Vue({
el: '#app',
  
  data: { 
      mixNumber:'',
      roundNumber: ''
  },
  mounted: function(){
  this.myFunction();
  },
  
   methods:{
    myFunction: function () {       
        this.mixNumber = Math.random();
        this.roundNumber = this.mixNumber.toString().split(".")[1];
    }   
   }

});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">

 My ID is: {{roundNumber}}
 
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!