How to do it...

Add accounting.js to your page. Refer to http://openexchangerates.github.io/accounting.js/ for more details on how to do it. If you are using JSFiddle though, you can just add it as an external resource to the left menu. You can add a link to CDN, which is serving it, for example, https://cdn.jsdelivr.net/accounting.js/0.3.2/accounting.js.

This filter will be extremely simple:

Vue.filter('currency', function (money) {   return accounting.formatMoney(money) })

You can try it out with a one-liner in HTML:

I have {{5 | currency}} in my pocket

It will default to dollars, and it will print I have $5.00 in my pocket.

Get Vue.js 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.