I am facing an issue with the formatting of a number displayed in a <p></p>
element. The number is coming from a range
input element that is bound to an amount
data property using v-model
. Even though I have a computed property to format the number, it doesn't appear correctly.
12,000
What I am seeing
12000
Check out this demo
new Vue({
el: "#app",
data: {
amount: 0
},
computed: {
formattedAmount(){
return this.amount.toLocaleString()
}
}
})
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<h2>Range Formatter</h2>
<p>{{formattedAmount}}</p>
<input type="range" id="range" v-model="amount" min="0" max="1000000">
</div>