[Vuejs]-Vue 3 – currency input filter

3👍

You could use a combination of a computed property and Intl.NumberFormat (or some currency npm package).

<template>
    <div>{{costCurrency}}</div>
</template>

<script>
const formatter = new Intl.NumberFormat('en-US', {style: 'currency', currency: 'USD'})

export default {
    props: {
        cost: Number
    },
    computed: {
        costCurrency() {
            return formatter.format(cost)
        }
    }
}
</script>

0👍

vue-currency-input supports Vue 3

Leave a comment