You can format the currency by writing your own code, but for now this is just a solution - when your application grows, you may need other currencies.
There is another problem with this:
- For EN-us - the dollar sign is always before the currency - $ 2.00,
- For the selected PL, you return the character after the amount as 2.00 zł.
I think the best option is to use a comprehensive solution for internationalization, for example, the vue-i18n library ( http://kazupon.imtqy.com/vue-i18n/ ).
I use this plugin and I do not need to worry about such things. Please look at the documentation - it is really simple:
http://kazupon.imtqy.com/vue-i18n/guide/number.html
so you just use:
<div id="app"> <p>{{ $n(100, 'currency') }}</p> </div>
and install EN-us to get $ 100.00 :
<div id="app"> <p>$100.00</p> </div>
or set PL to get PLN 100.00 :
<div id="app"> <p>100,00 zł</p> </div>
This plugin also provides various functions such as translations and date formatting.
Arkowsky
source share