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

268
Views
Round up a number in the v-model in vuejs

i want to round up this number in my input:

    <b-form-input id="amount_input" type="number"
     v-model="Math.ceil(form.contract.reward_cents / 100)"
      :state="validate(form.contract.reward_cents)"/>

I tried to do Math.ceil() but i'm getting this error enter image description here

Can anyone help me fix it?

I solved it like this:

    computed: {
        reward_cents () {
           return Math.ceil(this.form.contract.reward_cents / 100);       
        },
    }
<template>
<b-form-input id="amount_input" type="number" v-model="reward_cents"
    :state="validate(form.contract.reward_cents)"/>
</template>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Maybe you can try to use a computed property in v-model instead of an expression.

<b-form-input id="amount_input" type="number"
     v-model="reward_cents"
      :state="reward_cents"/>

<script>
  export default {
    computed: {
      reward_cents: {
        get() {
          return this.form.contract.reward_cents;
        },
        set(val) {
          this.form.contract.reward_cents = Math.ceil(val / 100);
        }
      }
    }
  }
</script>
about 4 years ago · Juan Pablo Isaza Report

0

you can follow:

<b-form-input 
id="amount_input" 
type="number"
:value="form.contract.reward_cents"
v-model="reward_cents"
@change="OnChange"
:state="validate(form.contract.reward_cents)"/>

data(){
    return: {
        reward_cents: 0
    }
}

methods: {
    OnChange(newVal){
        this.reward_cents = Math.ceil(newVal / 100);
    }
}
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!