currency
Formats a string number to a currency number using the browser's Intl object. Currency codes are based on ISO 4217.
Installation
Global install:
import Vue from 'vue';
import { currency } from 'vuetensils/src/filters';
Vue.filter('currency', currency);
Local install:
<script>
import { currency } from 'vuetensils/src/filters';
export default {
filters: {
currency,
},
};
</script>
Example
Custom Locale
You can specify the locale formatting by passing the filter your target ISO Language Code.
Custom Default Formatting
You can specify your own default currency and/or locale formatting by extending the filter and providing your target currency and ISO Language Code.
import Vue from 'vue';
import { currency } from 'vuetensils/src/filters';
const usd = str => currency(str, 'USD');
const euro = str => currency(str, 'EUR', 'de-DE');
Vue.filter('usd', usd);
Vue.filter('euro', euro);