[Vuejs]-Format currencies in a Vue component?

0👍

You can use toLocaleString to format numbers acording to the language and region you define.

Use Number.toLocaleString('es-CO') get this: 169.057.977,17

See this for a list of supported locales

See this example

<script>
export default {
  data() {
    return {
      conversionValue: 0,
      cryptoQuantity: 1
    }
  },
  async mounted () {
    this.conversionValue = await fetch("https://min-api.cryptocompare.com/data/price?fsym=btc&tsyms=COP").then(raw => raw.json()).then(json => json.COP)
  }
}
</script>

<template>
<input type="text" :value="(this.cryptoQuantity * this.conversionValue).toLocaleString('es-CO')"/>
</template>

Leave a comment