Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bogdy's avatar
Level 10

How to Replace a dot with a comma for a number in vue.js?

Hi,

How to Replace a dot with a comma for a number in vue.js?

for example:

new Vue({ el:'#app', data : { quantity : '0.25', }

and in HTML I have

<p>{{quantity}}</p>

the result is 0.25 but I want 0,25 (so with comma)

0 likes
6 replies
rin4ik's avatar
rin4ik
Best Answer
Level 50

like this

<p>{{outputQuantity}}</p>
computed: {
     outputQuantity(){
              return this.quantity.replace(".", ",");
     }
}
rawilk's avatar

You could also do it with a filter like this:

<p>{{ quantity | formatQuantity }}</p>
new Vue({
    el: '#app',

    data: {
        quantity: 0.25,
    },

    filters: {
        // you can call this whatever you want to
        formatQuantity (value) {
            return value.replace('.', ',');
        }
    }
});
2 likes
bogdy's avatar
Level 10

thanks wilk_randall

your method is also good

Please or to participate in this conversation.